-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Duplicate keys in Yaml fail silently #19526
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
Comments
So reading the links from the Symfony Yaml component where there are tests for this behaviour it links to http://yaml.org/spec/1.1/#id932806
So what I think we are missing is and issuing an appropriate warning |
Would it be possible to use a silenced warning or a flag to throw/warn on a duplicate key? |
@sstok I was just coding up a PR to introduce a new parse flag PARSE_EXCEPTION_ON_DUPLICATE |
I guess that the current behaviour was implemented based on the assumption that duplicate keys are allowed (see the quoted part of the spec at #19526 (comment)). However, as you can this part is from the YAML 1.1 spec, but we do follow the YAML 1.2 which does forbid duplicate keys (see the issue description). With this in mind I suggest to deprecate the current behaviour in Symfony 3.2 and throw a @symfony/deciders What are your thoughts on this? |
@xabbuh I agree: deprecate in 3.2; exception in 4.0. |
I agree too. Duplicate keys can be a pain to debug anyway. |
Does this effect the ability to include other config files? Like how the config_prod.yml file loads the config.yml file? Or is that a different concept that does that? |
@patrick-mcdougle That's a different concept which is specific to how the DependencyInjection and Routing component handle the merging of configuration files that have been parsed by the parser from the Yaml component. |
…ions on duplicates (Alex Pott) This PR was squashed before being merged into the 3.2-dev branch (closes #19529). Discussion ---------- Add Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19526 | License | MIT | Doc PR | Commits ------- cb362f2 Add Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates
…ions on duplicates (Alex Pott) This PR was squashed before being merged into the 3.2-dev branch (closes #19529). Discussion ---------- Add Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#19526 | License | MIT | Doc PR | Commits ------- cb362f2 Add Yaml::PARSE_EXCEPTION_ON_DUPLICATE to throw exceptions on duplicates
When the yaml parser reads
It will return an array with the first key. This is unfortunate for a couple of reasons.
Also it is the opposite behaviour to the PECL yaml parser (which behaves like PHP) so allowing users to swap between implementations can have interesting affects.
The text was updated successfully, but these errors were encountered: