Skip to content

Conversation

@zackman0010
Copy link

@zackman0010 zackman0010 commented Jan 6, 2026

When converting an environment to YAML and resolving placeholders, the produced YAML will sometimes be invalid. Specifically, this happens when a placeholder is replaced with a string that starts with {, usually {cipher}. { is a reserved character in YAML and needs to be quoted.

When SnakeYAML sees a string that starts with {, it will print it as a single-quoted string with all other strings remaining unquoted:

parent:
  encrypted: '{cipher}1234567890abcdef'
  reference: ${parent.encrypted}

Spring will then take this produced String and resolve the properties in it, creating invalid YAML:

parent:
  encrypted: '{cipher}1234567890abcdef'
  reference: {cipher}1234567890abcdef # Invalid YAML

This PR fixes the issue by running a second post-process step to wrap any values that start with a { in single-quotes, matching the rest of the YAML structure. The below screenshot shows an example of the added line of code running.
image

Fixes invalid YAML caused by the combination of `?resolvePlaceholders=true` and `spring.cloud.config.server.encrypt.enabled = false`

Signed-off-by: Zachary Sistrunk <[email protected]>
The invalid YAML can be caused by any string starting with a {, not just {cipher}

Signed-off-by: Zachary Sistrunk <[email protected]>
Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

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

Please add a test so we can guard against regressions

@zackman0010
Copy link
Author

Please add a test so we can guard against regressions

I've added a regression test, but I wasn't able to run it. For some reason, org.springframework.boot.restclient is saying it doesn't exist even when using a fresh clone. I'm not sure if something is wrong on my system or if there's a dependency missing. Do you have any ideas?

Signed-off-by: Zachary Sistrunk <[email protected]>
@spencergibb
Copy link
Member

Yes, it's a breaking change in boot, we will take care of it

@zackman0010
Copy link
Author

After merging in the latest commit from main, I was able to run my test and confirm it was successful.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants