spring-cloud-gcp: Spring framework 6.2 placeholder parser rewrite breaks the secret manager prefix sm://
Describe the bug Please provide details of the problem, including the version of Spring Cloud that you are using.
spring-cloud-gcp-starter-secretmanager: 5.8.0 Spring framework 6.2.0 (i.e, spring boot 3.4.0)
The rewrite of springs property placeholder parser (6.1 vs 6.2) changes the way default values are parsed. This change breaks hardcoded prefix of the secret manager, sm://.
For example a property defined as secret: ${sm://MY_SECRET} will be be parsed differently in spring framework 6.1 and 6.2. In 6.1 it will be resolved correctly to the actual secret. In 6.2 it will be parsed as //MY_SECRET (unless a property called sm is defined) which is clearly wrong
The workaround is to change the prefix in each application config to sm\://, e.g., secret: ${sm\://MY_SECRET}, but this is not only ugly but not at all intuitive to do.
At the very least I expect the documentation to be updated with the workaround.
Would it be possible to either
- Make the prefix configurable
- Add an alternative to the current prefix which does not contain
:, such assm//
Workaround (yaml)
unquoted_secret: ${sm\://MY_SECRET}
single_quoted_secret: '${sm\://MY_SECRET}'
double_quoted_secret: "${sm\\://MY_SECRET}"
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 28
- Comments: 24 (11 by maintainers)
Hi all, Spring Cloud GCP 6.0.0 has been released and fixes this issue by providing support for a new syntax for secrets in the form
sm@my_secret_id. Additionally, we followed up on how did the rewrite pointed out by @elg-entur break the behavior of secrets in the formsm://my_secret(it would now be interpreted as "computesmor default to//my_secret). However, the Spring folks fixed this regression as discussed in https://github.com/spring-projects/spring-framework/issues/34124 and was included in spring-framework:6.2.2 (part of spring-boot:3.4.2), which is part of spring-cloud-gcp:6.0.0.You can find more details on the release description. I’ll be closing this for now. Please file a new issue if anything was found with this spring-cloud-gcp 6.0.0 release.
Thanks @mieseprem for pointing folks to that issue.
Indeed we will soon support an additional syntax
sm@my_secret. This will solve the problems given the special treatment of the colon character. However, in order to not break any code we will still supportsm://, although with a warning when used. This work depends directly on Spring Boot 3.4.2 to be released by January 23rd, so we will soon follow with an upgrade.For those only following this issue (and not keep track on other ones), #3440 looks interesting:
@breun https://googlecloudplatform.github.io/spring-cloud-gcp/6.0.1/reference/html/index.html#secret-manager has the correct documentation. We are looking into correcting the already published 6.0.0 documentation.
Thanks for raising this and providing a workaround. Mine was in a single quoted string in a helm
values.yamlfile and a single backslash did the trick.spring.datasource.password: '${sm\://{{ .Values.env }}-database-password}'@diegomarquezp I see the Spring Cloud GCP Secret Manager documentation still mentions the
sm://syntax instead ofsm@.update: pls ignore my question. This question will be answered already there: https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/3320#issuecomment-2625021733
–
Hej @diegomarquezp , one question regarding this Statement:
When is ‘soon’ planned?
I ask, because 5.x is still the latest/current release.
Compatibility with Spring Project Versions does already list the 6.0 release, but it is nowhere else mentioned.
There is currently no version of Spring Cloud GCP yet that is compatible with Spring Cloud 2024.0 / Spring Boot 3.4 / Spring Framework 6.2 (see Compatibility with Spring Project Versions). I would recommend just waiting for Spring Cloud GCP 6 to be released before upgrading.
This will be solved by Framework 6.2.2, it’s in their next milestone’s roadmap - see https://github.com/spring-projects/spring-framework/issues/34124. We are still working on upgrading to Cloud 2024 as per https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/3320#issuecomment-2552199487.
It is in a properties file