← Back to issue list

yaml: detect and log warning on duplicate keys in snapcraft.yaml (CRAFT-553)

View original Github issue

Metadata

Project
snapcraft
Number
#3518
Type
pull request
State
merged
Author
cjp256
Labels
—
Created
Updated
Closed

Current evaluation

PR merged as 5c2a9d2f8 (commits 9b60bb1ef, 2f80e5313): snapcraft.yaml loading now detects duplicate YAML keys and logs a warning for each duplicate. Re-opened from #3517 for edge publishing.

Resolution: closed resolved

Reason: The PR itself was merged into snapcraft master as merge commit 5c2a9d2f8 ("Merge pull request #3518 from snapcore/duplicate-warnings"), adding commits 9b60bb1ef (detect/log duplicate keys) and 2f80e5313 (always enable the warning). cmatsuoka rebased it onto master in Sept 2021 and expanded warnings to all duplicated keys before merge.

Evaluated by: mr-cal-bot

No scores available.

Issue body

A very primitive check to warn if duplicate keys are found in the snapcraft.yaml. At the moment the file is loaded multiple times which may result in duplicate warnings (ha ha) which we need to address in future work. Given that there shouldn't be duplicates in YAML files, the extra verbosity should be OK. Signed-off-by: Chris Patterson <chris.patterson@canonical.com> - [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [ ] Have you successfully run `./runtests.sh static`? - [x] Have you successfully run `./runtests.sh tests/unit`? -----

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR merged as 5c2a9d2f8 (commits 9b60bb1ef, 2f80e5313): snapcraft.yaml loading now detects duplicate YAML keys and logs a warning for each duplicate. Re-opened from #3517 for edge publishing.
stealth/space-bunny-alpha — closed resolved Merged PR #3518 (5c2a9d2f8), adding duplicate-key detection and warnings for snapcraft.yaml; review expanded warnings to cover all duplicate keys.
qwen/qwen3.6-35b-a3b — — Merged into master after rebasing and approval. Adds a warning check for duplicate keys in snapcraft.yaml, logging all occurrences. Multiple warnings may trigger due to repeated file loads, to be optimized later.
qwen3.6-35b-a3b-mtp-q6 — — Merged into master. Adds duplicate key detection in snapcraft.yaml, logging warnings for all occurrences. Updated to report every duplicate instead of just the first, rebased, and approved.

Update history

No update history recorded yet.

Related work

  • Related To: snapcore/snapcraft#3517 (confidence 92%)

    Original PR with the same duplicate-key warning change; #3518 was re-opened from it (2021-05-04) to be on origin for edge publishing.

  • Related To: snapcore/snapcraft#3669 (confidence 85%)

    Follow-up PR merged as a40a34314, escalating duplicate-key warnings to hard errors when loading parts.

Related issues

Issue Project State Summary Similarity
#3517 yaml: detect and log warning on duplicate keys in snapcraft.yaml snapcraft closed Superseded by PR #3518, merged as 5c2a9d2f8, adding warnings for duplicate keys in snapcraft.yaml.
92%
#1942217 Please check for duplicated yaml keys snapcraft (launchpad) closed Duplicate snapcraft.yaml keys are now detected; warning support merged in canonical/snapcraft#3518 (5c2a9d2f8), with stricter handling from core22 in Snapcraft 7.0.
82%
#1770221 A snapcraft.yaml with more than 1 after: stanza doesn't warn or error snapcraft (launchpad) closed Duplicate `after:` stanzas in `snapcraft.yaml` now trigger a warning instead of silently using the last value. Resolved by enabling duplicate key warnings (commit 2f80e5313).
72%