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

Duplicate key allowed in map #39

Closed
slezakattack opened this issue May 22, 2020 · 11 comments
Closed

Duplicate key allowed in map #39

slezakattack opened this issue May 22, 2020 · 11 comments
Assignees
Milestone

Comments

@slezakattack
Copy link
Contributor

According to the YAML spec (https://yaml.org/spec/1.2/spec.html#id2802432), one of "maps" properties is to possess unique keys.

Discovered a bug that yamerl allows multiple keys when map is proplist and/or {detailed_constr, true} is set.

I have a PR to address the bug along with a test coming soon.

slezakattack added a commit to slezakattack/yamerl that referenced this issue May 22, 2020
@ronaldwind
Copy link

I would like to see this change merged. Is there any update for this issue? @dumbbell?

@dumbbell
Copy link
Collaborator

dumbbell commented Nov 9, 2021

Thanks for the direct ping, I don't get other notifications apparently...

After looking at the patch, it needs some improvements. For instance, it only works if the key is a scalar in detailed_constr mode. I will look into it in the coming days and keep you posted.

@flurin
Copy link
Contributor

flurin commented Jan 10, 2022

@dumbbell Is there an update on this issue? Anything that can be done to help with this?

@dumbbell
Copy link
Collaborator

dumbbell commented Jan 10, 2022

Thank you for the ping, I completely forgot about this and missed again the latest change made by @slezakattack... Working on this right now!

@flurin
Copy link
Contributor

flurin commented Jan 11, 2022

Awesome! Thank you. Any chance that could be added to a release?

@dumbbell
Copy link
Collaborator

Yes. I'm waiting a day or two for answers on other issues/pull requests, then I will cut a release.

@dumbbell dumbbell self-assigned this Jan 13, 2022
@dumbbell dumbbell added this to the v0.9.0 milestone Jan 13, 2022
dumbbell added a commit that referenced this issue Jan 13, 2022
This brings several bug fixes, including one which is a change of
behavior:

* @slezakattack implemented key deduplication in the construction of
  mappings, both when using proplists and maps (#39, #40).
* Report a parsing error if a block collection is unfinished when the
  end of the document is reached; e.g. when a `]` or `}` character is
  missing (#43, #50).
* Fix parsing of indented block scalar when they are finished by a
  document or directives end marker (#41, #51).

@kianmeng also fixed several typos (#47).

The Rebar configuration was updated to work with recent versions. While
working on that, the CI was switched from Travis to GitHub Actions.

Thank you to all contributors for their reports & patches!
@dumbbell
Copy link
Collaborator

@flurin: I just published yamerl 0.9.0 to Hex.pm.

Thank you for your patience!

@flurin
Copy link
Contributor

flurin commented Jan 13, 2022

Excellent, thank you!

@bobkocisko
Copy link

Oh no! I realize I'm late to the party here but we were relying on the duplicate key "feature" when in detailed_const mode to (ab)use the yaml syntax and create a much (c)leaner dsl for our purposes.

Is there any chance that you would consider wrapping these new changes under a configuration switch, to still support the old behavior while keeping the new behavior as default? Something like {allow_dupkeys , true} @dumbbell

I feel that it is reasonable in detailed_const mode to support invalid yaml. As I see it this provides a complete view of the document even if it is invalid in this way, which the developer can use or discard as needed.

@dumbbell
Copy link
Collaborator

Yes, I can introduce that option, @bobkocisko. I filed an issue for that (#52).

@bobkocisko
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants