-
Notifications
You must be signed in to change notification settings - Fork 478
Fixing parsing of YAML tags in sequences #6334
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
Conversation
fix(yaml): prevent duplicate tags in sequences In some YAML sequences, tags were being rendered twice: once in the startBracketPrefix and once attached to the sequence. This caused idempotency issues when formatting YAML. Update YamlParser to only attach a tag if startBracketPrefix is null, resolving the failing test case in openrewrite#5179.
|
Please add a test - e.g. the one mentioned in the issue description. |
|
@greg-at-moderne Thanks for taking a look, I see the test was added by @timtebeek |
rewrite-yaml/src/main/java/org/openrewrite/yaml/YamlParser.java
Outdated
Show resolved
Hide resolved
|
Thanks for coming up with the PR. |
greg-at-moderne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we merge it. I consider it an improvement. And if new information to light, we might find a better solution.
|
My vague memory is that it felt like a bodge to me because it didn't parse the value as a 'Tag' correctly so potentially would have cases where if you tried to rewrite tags it might not behave as expected. It definitely felt like it worked for me and I couldn't find the case where it failed! |
fix(yaml): prevent duplicate tags in sequences
In some YAML sequences, tags were being rendered twice: once in the startBracketPrefix and once attached to the sequence. This caused idempotency issues when formatting YAML.
What's changed?
A minor update to
YamlParserto prevent duplicate tags in sequences. The parser now only attaches a tag to a sequence ifstartBracketPrefixis null, resolving the idempotency issue.What's your motivation?
Anything in particular you'd like reviewers to focus on?
SequenceStartEventhandling inYamlParser:Reviewers
@greg-at-moderne, @aet2505