Skip to content

[Yaml] Duplicate keys not reported when key is defined with NULL value #57262

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

Closed
olsavmic opened this issue May 31, 2024 · 0 comments · Fixed by #57261
Closed

[Yaml] Duplicate keys not reported when key is defined with NULL value #57262

olsavmic opened this issue May 31, 2024 · 0 comments · Fixed by #57261

Comments

@olsavmic
Copy link
Contributor

Symfony version(s) affected

7+, 6+, 5+

Description

Duplicate keys are not valid by definition in YAML. The current implementation contains a bug that allows a key to be defined multiple times when the value is not set.

How to reproduce

services:
    Foo:
    Bar:
    Foo:

is invalid YAML but the YAML parser is fine with this.

Possible Solution

No response

Additional Context

No response

@olsavmic olsavmic added the Bug label May 31, 2024
@fabpot fabpot closed this as completed Jun 2, 2024
fabpot added a commit that referenced this issue Jun 2, 2024
…avmic)

This PR was squashed before being merged into the 7.2 branch.

Discussion
----------

[Yaml] Throw on duplicate key even when value is NULL

| Q             | A
| ------------- | ---
| Branch?       | 5.4 (since v3.0)
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fix #57262
| License       | MIT

Duplicate keys are not valid by definition in YAML. The current implementation contains a bug that allows a key to be defined multiple times when the value is not set.

```yaml
services:
    Foo:
    Bar:
    Foo:
```

Extends symfony/yaml@8094454
to throw when a key is set twice in YAML without a value.

It may be technically a breaking change (as it suddenly makes some yaml-like files invalid), even though I'd classify it as a bugfix (as by definition, such files were not valid).

If we classify it as a bug, we should probably backport the fix to the oldest maintained version.

Commits
-------

f9df19b [Yaml] Throw on duplicate key even when value is NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants