Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Spring conditional annotation @ConditionalOnProperty prevents creating of bean in-casse Azure key vault secrets name is in camelCase, with Groovy framework. #23815

Closed
gsbindhani opened this issue Aug 30, 2021 · 4 comments
Assignees
Labels
azure-spring All azure-spring related issues azure-spring-keyvault Spring keyvault related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@gsbindhani
Copy link

gsbindhani commented Aug 30, 2021

Environment
Groovy: 2.5.10
spring-boot-starter: 2.5.2
azure-spring-boot-starter-keyvault-secrets: 3.6.0

Summary
Spring conditional annotation @ConditionalOnProperty not satisfying the condition when the secret is in camel case**(testing-propInCamelCase)** in the azure key vault.

Whereas able to read the properties using @value annotation.

To Reproduce
Create a secret as testing-propInCamelCase in the azure key vault with any value.

Try to create a spring bean using the property using the @ConditionalOnProperty, in the below, you will see the first bean is not getting created whereas the second one is.

   @Bean
   @ConditionalOnProperty(name = "testing.propInCamelCase") //Reading in camelCase
   public String testingConditionalBeanWithCamelCase() {
   	//Bean is not getting created, whereas it should. Here is the issue
   	logger.info("Bean instantiated from prop(camelCase): testing.propInCamelCase");
   	return "done";
   }
   
   @Bean
   @ConditionalOnProperty(name = "testing.propincamelcase") //Reading in lowercase
   public String testingConditionalBeanWithLowerCase() {
   	//Bean is getting created
   	logger.info("Bean instantiated from prop(lowerCase): testing.propincamelcase");
   	return "done";
   }

Expected behavior
As Azure is lowering the case of the properties/secrets, the conditional property should work for both cases as it's working in the below case while reading the secrets with @value annotation. In both cases, the value is loading from the secrets.

	@Value("${testing.propInCamelCase:}") //Reading in camelCase
	String propInCamelCase; //Accessing the value
	
	@Value("${testing.propincamelcase:}") //Reading in lowercase
	String propInLowerCase; //Accessing the value

Is there any reason it is working while reading the properties not while using the conditional on a property?

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Aug 30, 2021
@joshfree joshfree added azure-spring All azure-spring related issues azure-spring-keyvault Spring keyvault related issues. Client This issue points to a problem in the data-plane of the library. labels Aug 30, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 30, 2021
@joshfree
Copy link
Member

@chenrujun could you please follow up with @gsbindhani ?

@chenrujun chenrujun self-assigned this Aug 30, 2021
@chenrujun chenrujun added this to the [2021] October milestone Aug 30, 2021
@chenrujun chenrujun assigned ZhuXiaoBing-cn and unassigned chenrujun Sep 1, 2021
@chenrujun chenrujun self-assigned this Sep 5, 2021
@chenrujun chenrujun moved this to Todo in Spring Cloud Azure Nov 5, 2021
@chenrujun chenrujun modified the milestones: [2021] December, Backlog Nov 5, 2021
@chenrujun chenrujun removed their assignment Feb 8, 2022
@yiliuTo yiliuTo assigned chenrujun, jialigit and Netyyyy and unassigned chenrujun and jialigit Feb 10, 2022
@chenrujun
Copy link

It's a new problem that different to all other known problems.
@Netyyyy , please help to investigate it.

@hui1110
Copy link
Contributor

hui1110 commented Mar 23, 2022

Hi @gsbindhani, thanks for bringing this up. For your question, in the version you are using, you can set another entry azure.keyvault.case-sensitive-keys=true in the properties file, by case-sensitive secret names to can meet your expectations. In version 4. x without GA, this pr fixes the problem. After 4. x version GA, we recommend you to try our latest version.

@hui1110
Copy link
Contributor

hui1110 commented Mar 24, 2022

Close this issue, fix it in #27827.

@hui1110 hui1110 closed this as completed Mar 24, 2022
Repository owner moved this from In Progress to Done in Spring Cloud Azure Mar 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
azure-spring All azure-spring related issues azure-spring-keyvault Spring keyvault related issues. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Archived in project
Development

No branches or pull requests

9 participants