Skip to content

Conversation

@rs017991
Copy link
Member

📌 Description

Previously the installation of VaultPropertySource was only conditional on the VaultTemplate class being present, making it impossible to disable so long as it is on the classpath (disrupting tests, feature flags and other scenarios where it is not feasible/desirable to have a valid OCI Session)

Aspects of the problem (all addressed in this PR):

  1. It did not consult the existing spring.cloud.oci.vault.enabled prop
    • If one attempted to disable it in this way and set no other properties, they would encounter an NPE (as shown in Error # 1 down below)
  2. It did not validate the presence of the spring.cloud.oci.vault.property-sources prop
    • So even with a valid OCI Session, omitting that prop would result in it creating a bunch of pointless clients, followed by an NPE (as seen in Error # 2 down below)
  3. The tests did not catch these problems because none of the tests enabled the PostProcessor (ApplicationContextRunner-style tests are intentionally stripped of many Spring Boot default behaviours, which must be re-introduced as appropriate)

While I was in the tests, I noticed that there were no tests for the happy path of VaultPropertySource either, so I went ahead and added one. This is isolated to its own commit (for your reviewing pleasure), but may be squashed or split into a separate PR if desired.

✅ Checklist

  • Code builds and runs locally
  • Tests have been added/updated (if applicable)
  • Documentation has been updated (if applicable)
  • Follows project coding style and conventions
  • Signed the Oracle Contributor Agreement (OCA) to contribute to this project

📸 Logs

Error # 1

(when setting spring.cloud.oci.vault.enabled: false and supplying no auth config)

java.lang.NullPointerException: Missing user in config.
For more information about OCI configuration file and how to get required information, see https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
	at com.oracle.bmc.util.internal.Validate.notNull(Validate.java:24)
	at com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider$ConfigFileSimpleAuthenticationDetailsProvider.<init>(ConfigFileAuthenticationDetailsProvider.java:205)
	at com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider.<init>(ConfigFileAuthenticationDetailsProvider.java:84)
	etc...
	at com.oracle.cloud.spring.vault.VaultPropertySource.configure(VaultPropertySource.java:41)
	at com.oracle.cloud.spring.vault.VaultEnvironmentPostProcessor.postProcessEnvironment(VaultEnvironmentPostProcessor.java:20)
	etc...

Error # 2

(when supplying valid auth config, yet choosing not to set the spring.cloud.oci.vault.property-sources prop)

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "com.oracle.cloud.spring.vault.VaultProperties.getPropertySources()" is null
	at com.oracle.cloud.spring.vault.VaultPropertySource.configure(VaultPropertySource.java:47)
	at com.oracle.cloud.spring.vault.VaultEnvironmentPostProcessor.postProcessEnvironment(VaultEnvironmentPostProcessor.java:20)
	etc...

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 31, 2025
Copy link
Member

@anders-swanson anders-swanson left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@anders-swanson anders-swanson merged commit 4a6c079 into oracle:main Jan 5, 2026
2 checks passed
@rs017991 rs017991 deleted the vaultEnableFix branch January 6, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants