[Fleet] Automatically quote vars that start with asterisks or ampersands #126919
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #121934
We ran into this problem about a year ago in #91401. Initially that was fixed by escaping all special YAML characters in #91418. However, this created another issue and this was then reverted and replaced with a validation error in #93585.
While #93585 has a good explanation of why this problem presents itself when converting between YAML to JSON back to YAML, I don't agree with the conclusion that putting the onus on package developers and users makes sense. We should be able to handle at least the most common scenarios (like a string that starts with a
*
).It appears the initial implementation of this in #91418 was too heavy handed and could be re-implemented in a safer way. Instead of quoting any strings that contain any special characters at any position, this PR will only quote strings that start with
*
or&
.How to test
Start Kibana with this configuration (needs to be the Cloud policy w/o the APM policy added):
Run this curl command to setup the correct APM state:
*
setting.Checklist
Delete any items that are not applicable to this PR.