← Back to issue list

Please check for duplicated yaml keys

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1942217
Type
issue
State
closed
Author
~mvo
Labels
craft-829
Created
Updated
Closed

Current evaluation

Duplicate snapcraft.yaml keys are now detected; warning support merged in canonical/snapcraft#3518 (5c2a9d2f8), with stricter handling from core22 in Snapcraft 7.0.

Resolution: closed resolved

Reason: PR canonical/snapcraft#3518 merged as commit 5c2a9d2f8 and added duplicate-key warnings. Maintainer comments confirmed stricter duplicate-key rejection applies from core22 in Snapcraft 7.0, while older supported bases warn.

Evaluated by: mr-cal-bot

No scores available.

Issue body

In YAML it is not allowed to have duplicated map keys like: ``` map: key: key: ``` But unfortunately py-yaml and go-yaml.v2 allow this and do not warn or error. When moving to go-yaml.v3 we noticed this issue. It is unclear if any real world snaps are affected by this but we should make sure we at least to not get more. But it would be nice if snapcraft could detect this and warn. I created a similar bug and a patch for review-tools in https://bugs.launchpad.net/review-tools/+bug/1942200 Maybe this can be useful to you folks, the duplicate detection can probably be reused in exactly the same way.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Duplicate snapcraft.yaml keys are now detected; warning support merged in canonical/snapcraft#3518 (5c2a9d2f8), with stricter handling from core22 in Snapcraft 7.0.
stealth/space-bunny-alpha — closed resolved Fixed: PR #3518 (merged 5c2a9d2f8) added duplicate-key warnings in snapcraft.yaml, then PR #3669 (commit a40a34314, snapcraft 7.0) made duplicate keys a hard error from core22 onwards; older bases only warn.
stealth/space-bunny-alpha — closed resolved Duplicate YAML-key detection was implemented in canonical/snapcraft#3518 (commit 5c2a9d2f8), adding warnings for repeated keys.
qwen/qwen3.6-35b-a3b — — Closed without implementation. The request to detect and warn about duplicate YAML keys was abandoned. No code changes or follow-up occurred despite the suggestion to reuse detection logic from review-tools.
qwen/qwen3.6-35b-a3b — — Closed without resolution. The request to detect duplicate YAML keys was abandoned due to zero comments and prolonged inactivity, with no implementation or follow-up provided.
qwen/qwen3.6-35b-a3b — — Abandoned due to prolonged inactivity. The request to detect duplicate YAML keys was never implemented or addressed by maintainers. No resolution or fix was provided.
qwen3.6-35b-a3b-mtp-q6 — — Closed without action. The request to detect duplicate YAML keys was abandoned. The author suggested reusing detection logic from review-tools, but no implementation or fix was applied.

Update history

Date Change
created

Related work

  • Likely Fixed By: canonical/snapcraft#3518 (confidence 100%)

    Merged duplicate-key detection and warning support via commit 5c2a9d2f8.

  • Related To: canonical/snapcraft#3669 (confidence 94%)

    Follow-up PR merged as ab5970540 with commit a40a34314 to reject duplicate keys, supporting the stricter core22 behavior.

Related issues

Issue Project State Summary Similarity
#3518 yaml: detect and log warning on duplicate keys in snapcraft.yaml (CRAFT-553) snapcraft merged 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.
82%
#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.
81%
#1686557 Duplicated error message during yaml validation snapcraft (launchpad) closed Fixed duplicated YAML validation errors in snapcore/snapcraft#1347 (commit 9e8e336de) by removing an early exit and consolidating CLI error handling.
71%