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

Escaped character in nested placeholder not detected properly and leads to invalid parts #34289

Closed
semeiskii opened this issue Jan 20, 2025 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@semeiskii
Copy link

semeiskii commented Jan 20, 2025

Problem
After upgrade from Spring Boot 3.3 to Spring Boot 3.4 a property which uses custom loader and contains placeholder inside it is not resolved properly.

application.yaml:

spring:
  config:
    import: sm-stub://

app:
  environment: qa
  a-service-url: ${sm-stub\://projects/my-project/secrets/${app.environment}_a-service_url/versions/latest}

In the application:

@Value("${app.a-service-url}")
private String aServiceUrl;

The resolved value is "//projects/my-project/secrets/qa_a-service_url/versions/latest" [NOK]
Expected value is the one returned by the custom property source for the "projects/my-project/secrets/qa_a-service_url/versions/latest" location.

Minimal reproducible example
https://github.com/semeiskii/spring-boot-property-resolving-bug

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 20, 2025
@bclozel
Copy link
Member

bclozel commented Jan 20, 2025

It looks like a duplicate of #34124. Please check the discussion there for best practices.
Also, this should be "fixed" in Spring Framework 6.2.2 already so you can verify that your application works with that version right now.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2025
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 20, 2025
@semeiskii

This comment has been minimized.

@bclozel bclozel reopened this Jan 20, 2025
@bclozel bclozel added status: waiting-for-triage An issue we've not yet triaged or decided on and removed status: duplicate A duplicate of another issue labels Jan 20, 2025
@snicoll snicoll self-assigned this Jan 20, 2025
@snicoll
Copy link
Member

snicoll commented Jan 20, 2025

Thanks for the report and the sample.

As pointed out in the related issue, : is a reserved character that you shouldn't be using. That double indirection that you use makes ${sm-stub://projects/my-project/secrets/${app.environment}_a-service_url/versions/latest} very artificial.

If you insist on it, you can escape the separator. However, you need to double backslash it for the backslah to be taken into account, i.e.:

app.a-service-url:${sm-stub\\://projects/my-project/secrets/${app.environment}_a-service_url/versions/latest}

Unfortunately, this makes me discover another regression in the parser so I'll use this issue to fix it.

@snicoll snicoll changed the title Placeholder with custom prefix which includes a placeholder is resolved properly Escaped character in nested placeholder not detected properly and leads to invalid Parts Jan 20, 2025
@snicoll snicoll added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 20, 2025
@snicoll snicoll added this to the 6.2.3 milestone Jan 20, 2025
@semeiskii

This comment has been minimized.

@snicoll

This comment has been minimized.

@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Jan 20, 2025
@jhoeller jhoeller changed the title Escaped character in nested placeholder not detected properly and leads to invalid Parts Escaped character in nested placeholder not detected properly and leads to invalid parts Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

5 participants