You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
code-metrics yaml_subset.py: quote mid-value swallows comments; duplicate key in a sequence item reports the wrong line #6699
No related issue: found while porting the parser for #6306 (PR #6669).
Problem
plugins/code-metrics/scripts/yaml_subset.py likely has two bugs that its JavaScript port in plugins/user-experience/scripts/lib/yaml-subset.mjs had and fixed in #6669:
A quote mid-value swallows a trailing comment.stripComment treats any ' or " as the start of a quoted string, even inside a plain value, so title: it's fine # comment parses as "it's fine # comment" instead of "it's fine".
A duplicate key inside a sequence item is reported on the wrong line. For - job: a\n id: x\n job: b\n, the error names line 1 (the dash line) instead of line 3.
The port fixed both in 1d5a3fca3f: a quote opens only where a value starts (line start, after : , - , [ or ,), and the sequence item's first key is passed into the mapping so the duplicate check fires on its own line. See the tests "quotes and comments in plain values" and "a duplicate key in a sequence-item mapping is reported on its own line" in plugins/user-experience/tests/yaml-subset.test.mjs.
Unverified against the Python: confirm each with a failing test first.
Acceptance criteria
A failing test reproduces each bug against yaml_subset.py, then passes after the fix.
Thanks for the detailed report. I confirmed both bugs by reading plugins/code-metrics/scripts/yaml_subset.py:
_strip_comment opens a quote on any '/" regardless of position, so it's fine # comment never closes the quote and the # comment is never stripped.
In _sequence, when a key from the dash line's inline mapping entry collides with a key parsed later via the nested _mapping call, the duplicate-key error reuses the outer number (the dash line), not the colliding key's own line.
No duplicate open issues found for yaml_subset. This looks like a small, self-contained, well-scoped fix (port the two test cases and matching fixes from the JS version), so I'm marking it a good first issue at low priority since it's a parser edge case with a known, already-tested fix pattern to follow.
Owner batch-ratified this admission in an attended session on 2026-10-12: work-class: scoped. Rule: class C1-C3, no trust surface, the independent check confirmed the recorded decision, and no owner step remains.
Type: Bug Summary: Fix two parser bugs in code-metrics' YAML subset reader: a quote mid-value swallows a trailing comment, and a duplicate key in a sequence item is reported on the dash line.
Current behavior:
Comment stripping treats any ' or " as opening a quoted string, so title: it's fine # comment keeps # comment in the value.
For - job: a / id: x / job: b, the duplicate-key error names line 1 (the dash line) instead of line 3.
Desired behavior:
A quote opens a quoted string only where a value starts (line start, after : , - , [ or ,); title: it's fine # comment parses as it's fine.
A duplicate key inside a sequence-item mapping is reported on the line of the duplicate key.
All other parses are unchanged.
Key interfaces:
The code-metrics YAML subset parser's comment stripping and its sequence-item mapping parse.
Error messages for duplicate keys: the reported line number.
Acceptance criteria:
A new test for title: it's fine # comment expects it's fine.
A new test for a duplicate key in a sequence-item mapping expects the error on the duplicate key's line.
The work-resolve-issue run that agent-ready started failed before it reported, or the token broker refused it because its workflow files differ from main's. work-unblock removed and added agent-ready back to start a fresh run on main's workflow files. It does this once per version of those files, so if this run fails the same way, a person looks at it.
Activity
github-actions commentedon Oct 10, 2026
Thanks for the detailed report. I confirmed both bugs by reading
plugins/code-metrics/scripts/yaml_subset.py:_strip_commentopens a quote on any'/"regardless of position, soit's fine # commentnever closes the quote and the#comment is never stripped._sequence, when a key from the dash line's inline mapping entry collides with a key parsed later via the nested_mappingcall, the duplicate-key error reuses the outernumber(the dash line), not the colliding key's own line.No duplicate open issues found for
yaml_subset. This looks like a small, self-contained, well-scoped fix (port the two test cases and matching fixes from the JS version), so I'm marking it a good first issue at low priority since it's a parser edge case with a known, already-tested fix pattern to follow.Automated triage. A maintainer reviews it.
kyle-sexton commentedon Oct 13, 2026
Owner batch-ratified this admission in an attended session on 2026-10-12: work-class: scoped. Rule: class C1-C3, no trust surface, the independent check confirmed the recorded decision, and no owner step remains.
kyle-sexton commentedon Oct 18, 2026
Agent Brief
Type: Bug
Summary: Fix two parser bugs in code-metrics' YAML subset reader: a quote mid-value swallows a trailing comment, and a duplicate key in a sequence item is reported on the dash line.
Current behavior:
'or"as opening a quoted string, sotitle: it's fine # commentkeeps# commentin the value.- job: a/id: x/job: b, the duplicate-key error names line 1 (the dash line) instead of line 3.Desired behavior:
:,-,[or,);title: it's fine # commentparses asit's fine.All other parses are unchanged.
Key interfaces:
Acceptance criteria:
title: it's fine # commentexpectsit's fine.scripts/run-test-file.sh plugins/code-metrics/scripts/test_yaml_subset.pypasses, existing tests included.scripts/check-changelog-fragments.shpasses.Out of scope:
This was generated by AI during backlog shaping. The owner approved this in an attended backlog-shaping session on 2026-10-17.
melodic-automation-lanes commentedon Oct 18, 2026
The work-resolve-issue run that
agent-readystarted failed before it reported, or the token broker refused it because its workflow files differ from main's. work-unblock removed and addedagent-readyback to start a fresh run on main's workflow files. It does this once per version of those files, so if this run fails the same way, a person looks at it.