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

Tag nodes are now not allowed in mapping nodes, except if the mapping node has one element #525

Closed
jbutA opened this issue Nov 12, 2024 · 7 comments · Fixed by #526
Closed
Labels
bug Something isn't working parser

Comments

@jbutA
Copy link

jbutA commented Nov 12, 2024

Describe the bug
Before the recent updates, mapping nodes could have tag nodes. Now this gives an error. Unless the mapping node has one element.

To Reproduce

Examples of it failing and not failing:
https://go.dev/play/p/ZiES84oWFCw

Expected behavior
Consistent behaviour one way or the other, regardless of number of elements.

Screenshots
If applicable, add screenshots to help explain your problem.

Version Variables

  • Go version: [e.g. 1.23 ]
  • go-yaml's Version: [e.g. v1.13.8 ]

Additional context
Add any other context about the problem here.

@jbutA jbutA added the bug Something isn't working label Nov 12, 2024
@goccy goccy added the parser label Nov 12, 2024
@goccy
Copy link
Owner

goccy commented Nov 12, 2024

Thank you for your reports. Since it's the correct behavior for both to result in an error, I'll fix the behavior when there is only one element.

@jbutA
Copy link
Author

jbutA commented Nov 12, 2024

Thanks for your extremely fast response!

If I may ask a question. I've seen examples of global tags applied to mapping nodes, but couldn't find any of local tags on mapping nodes in the yaml spec.

Does this being correct behaviour originate in the library or in the spec or somewhere else?

@goccy
Copy link
Owner

goccy commented Nov 12, 2024

For example, the following tag is fine, but if an invalid tag is specified, it should result in an error.

mapping: !!map
  scalar1: 1

@goccy
Copy link
Owner

goccy commented Nov 12, 2024

@jbutA I've fixed this problem with #526 and it merged into master branch.
Please confirm this ?

@jbutA
Copy link
Author

jbutA commented Nov 12, 2024

The behaviour now is that no application-specific tags (!someTagName) are allowed in any context. Is that necessary at the parsing stage? User code that hooks into the syntax tree can have uses for the application-specific tags, right?

@jbutA
Copy link
Author

jbutA commented Nov 12, 2024

But I can confirm that the behaviour is now consistent.

@goccy
Copy link
Owner

goccy commented Nov 12, 2024

I've supported application-specific local tag with this PR ( #527 ).
These provided examples are processed valid yaml. Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants