Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

Plan to fix App Configuration validation when disabled

  • Understand the problem: Connection string is being validated even when spring.cloud.azure.appconfiguration.enabled is false
  • Identify the root cause: validateAndInit() is called in AzureAppConfigDataLocationResolver.loadProperties() without checking if app configuration is enabled
  • Modify AzureAppConfigDataLocationResolver.isResolvable() to check if app configuration is enabled before validating store configuration
  • Add test case to verify connection string is not validated when app configuration is disabled
  • Update existing tests to include enabled flag check in mocks
  • Run tests to ensure no regression - all 20 tests in AzureAppConfigDataLocationResolverTest pass
  • Run full module tests to ensure no other tests are broken - all 190 tests pass
  • Verify the fix resolves the original issue
  • Update sdk/spring/CHANGELOG.md following existing pattern

Summary of Changes

The fix modifies AzureAppConfigDataLocationResolver.isResolvable() to check the spring.cloud.azure.appconfiguration.enabled property before attempting to validate store configuration. When enabled is false, the resolver returns false early, preventing any validation of connection strings or endpoints.

Key changes:

  1. Added early return in isResolvable() when spring.cloud.azure.appconfiguration.enabled is false
  2. Added test case testIsResolvableWhenAppConfigurationIsDisabled() to verify the fix
  3. Updated existing test cases to properly mock the enabled property
  4. Updated CHANGELOG.md with bug fix entry

Impact:

  • When spring.cloud.azure.appconfiguration.enabled is false, the application will no longer attempt to validate connection strings
  • This allows developers to run tests and local applications without providing valid connection strings when App Configuration is disabled
  • All existing tests continue to pass, ensuring backward compatibility
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] App Configuration spring.cloud.azure.appconfiguration.stores[0].connection-string is validated when spring.cloud.azure.appconfiguration.enabled is false</issue_title>
<issue_description>Describe the bug
spring.cloud.azure.appconfiguration.stores[0].connection-string is validated when spring.cloud.azure.appconfiguration.enabled is false
The connection string, being a secret, is typically specified from outside (program argument, env var, etc).
When running tests, and when running the app locally with feature flags under feature-management.feature-flags, spring.cloud.azure.appconfiguration.enabled is false and the connection string is left empty. The connection string should not have to be specified and should not be validated since it's not needed in these cases.

Exception or Stack Trace

19:40:46.412 ERROR main o.s.b.SpringApplication Application run failed 
java.lang.IllegalStateException: Unable to load config data from 'azureAppConfiguration'
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:142)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:127)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:120)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:102)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:113)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:102)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:94)
	at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:106)
	at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:98)
	at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
	at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:129)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:245)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:232)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:96)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:134)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:117)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
	at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:81)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:64)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:63)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:353)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)
	at com.att.training.springboot.examples.FeatureManagementApplication.main(FeatureManagementAppli...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Azure/azure-sdk-for-java#47587

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix validation of connection string when app configuration is disabled Fix: Skip App Configuration validation when feature is disabled Dec 22, 2025
Copilot AI requested a review from rujche December 22, 2025 01:32
@rujche
Copy link
Member

rujche commented Dec 22, 2025

Hi, @mrm9084 , could you please help to review this PR?

@rujche rujche marked this pull request as ready for review December 22, 2025 01:37
@rujche rujche requested a review from mrm9084 as a code owner December 22, 2025 01:37
Copilot AI review requested due to automatic review settings December 22, 2025 01:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where App Configuration validates connection strings even when spring.cloud.azure.appconfiguration.enabled=false, preventing applications from running tests or local development without providing unnecessary credentials.

Key changes:

  • Added early check for the enabled property in isResolvable() before validating store configuration
  • Added comprehensive test coverage for the disabled state
  • Updated all existing tests to mock the enabled property check

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
AzureAppConfigDataLocationResolver.java Added early return in isResolvable() when enabled=false, preventing validation of connection strings
AzureAppConfigDataLocationResolverTest.java Added new test for disabled state and updated all existing tests to mock the enabled property binding

@rujche
Copy link
Member

rujche commented Dec 22, 2025

@copilot Update sdk/spring/CHANGELOG.md, following existing pattern in sdk/spring/CHANGELOG.md.

Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot Update sdk/spring/CHANGELOG.md, following existing pattern in sdk/spring/CHANGELOG.md.

Updated CHANGELOG.md following the existing pattern in commit 4226065.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants