Skip to content

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

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

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

olsavmic
Copy link
Contributor

@olsavmic olsavmic commented May 31, 2024

Q A
Branch? 5.4 (since v3.0)
Bug fix? yes
New feature? no
Deprecations? no
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.

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.

@olsavmic olsavmic requested a review from xabbuh as a code owner May 31, 2024 12:44
@carsonbot carsonbot added this to the 7.2 milestone May 31, 2024
@olsavmic olsavmic force-pushed the mo-throw-on-duplicate-key branch from 73fc4ff to 94d306a Compare May 31, 2024 12:50
@xabbuh xabbuh modified the milestones: 7.2, 5.4 May 31, 2024
@olsavmic olsavmic force-pushed the mo-throw-on-duplicate-key branch from 94d306a to 0287305 Compare May 31, 2024 13:19
@olsavmic olsavmic changed the base branch from 7.2 to 5.4 May 31, 2024 13:20
@fabpot
Copy link
Member

fabpot commented Jun 1, 2024

IIUC, currently, this file is valid and has the "expected" behavior. So, throwing an exception now is a BC break that we cannot merge in 5.4. I would vote to do it in 7.2 only and add a note in the CHANGELOG file.

@OskarStark OskarStark added the Yaml label Jun 1, 2024
@carsonbot carsonbot changed the title Throw on duplicate key even when value is NULL [Yaml] Throw on duplicate key even when value is NULL Jun 1, 2024
@olsavmic olsavmic force-pushed the mo-throw-on-duplicate-key branch from 0287305 to f7cf88c Compare June 2, 2024 18:13
@olsavmic olsavmic changed the base branch from 5.4 to 7.2 June 2, 2024 18:19
@olsavmic
Copy link
Contributor Author

olsavmic commented Jun 2, 2024

The base was changed to 7.2 and I've updated the changelog file. Thank you!

@fabpot fabpot modified the milestones: 5.4, 7.2 Jun 2, 2024
@fabpot fabpot force-pushed the mo-throw-on-duplicate-key branch from 0f44bec to f9df19b Compare June 2, 2024 19:15
@fabpot
Copy link
Member

fabpot commented Jun 2, 2024

Thank you @olsavmic.

@fabpot fabpot merged commit 9f11f46 into symfony:7.2 Jun 2, 2024
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Yaml] Duplicate keys not reported when key is defined with NULL value
5 participants