Repository navigation
fix(pilot-report-validator): ignore YAML comments in frontmatter - #2392
Open
leninworld wants to merge 1 commit into
Open
leninworld wants to merge 1 commit into
leninworld wants to merge 1 commit into
Conversation
docs/pilot-report-template.md has `#` comment lines in its frontmatter, but the validator read YAML comments as values: a column-0 `# ...` line was appended to the previous key's value (so `date: 2026-06-29` followed by a comment was an invalid date), a column-0 comment with a colon became a key of its own (`# NOTE: <owner>/<repo>` was an unfilled placeholder), and `profile: asf # note` was an invalid profile. parse_frontmatter() now skips column-0 `#` lines, except while a multi-line quoted value is still open, and drops an inline comment from the value on a `key:` line with the rule spec-status-index got in apache#2344: an unquoted value loses a `#` comment that starts it or follows a space or tab, and a quoted value keeps its quotes and loses only a comment after its closing quote. Other lines are read as before. Generated-by: Codex (gpt-5.6-sol)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #2391.
Summary
pilot-report-validatorread YAML#comments in a report's frontmatter as values, althoughdocs/pilot-report-template.mditself has#comment lines there. A column-0# ...line was appended to the previous key's value (date: 2026-06-29followed by a comment became an invalid date), a column-0 comment with a colon became a key of its own (# NOTE: use <owner>/<repo>was reported as an unfilled placeholder), andprofile: asf # asf | non-asf | customwas an invalid profile.parse_frontmatter()now skips column-0#lines, except while a multi-line quoted value is still open, and drops a trailing comment from the value on akey:line with the rulespec-status-indexgot in fix(spec-status-index): drop inline comments from frontmatter values #2344 (the same two regexes, copied because the packages are separate): an unquoted value loses a#comment that starts it or follows a space or tab, and a quoted value keeps its quotes and loses only a comment after its closing quote (\"and''honoured; an unclosed quote, or text after the closing quote, is kept as written). The key-line rule runs before the block-scalar header check, sonotes: | # xis still a block scalar. All other lines are read as before.Type of change
tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)Test plan
prek run --all-filespasses:prek run --all-files --skip workspace-pytestpasses, andprek run workspace-pytest --from-ref origin/main --to-ref HEADpasses.For Python packages touched:
uv run pytest/ruff check/mypypasses:tools/pilot-report-validator78 passed;ruff check,ruff format --checkandmypyare clean.Other: new tests in
tools/pilot-report-validator/tests/test_pilot_report_validator.py. Onmain(2e5cea2) 13 fail: column-0 comments with and without a colon, after a block scalar and after a closed multi-line quoted value, a comment with a colon that holds<owner>/<repo>,profile: asf # ...,date: 2026-06-29\t# x, a quoted value with a comment (plus\"and''escapes),notes: | # block, the report from the issue, and the real template filled in with comment lines added afterdate:andprofile:. Guard cases pass onmainand with the fix:C# tooling,a #b(a no-break space is not YAML whitespace), an unclosed quote, text after a closing quote, and a column-0# y"line inside an open multi-line quoted value (kept as content, as onmainand in PyYAML).Other: each branch fails a case when removed or changed (10 mutations): the column-0 skip, the open-quote guard (removed, never set, never cleared), the key-line comment, the quoted branch,
[ \t]widened to\s,\"escapes,''escapes, and cutting an unclosed quote.Other: a generated sweep of 354 frontmatter documents compared with PyYAML 6.0.2:
maindiffers on 207, the fix on 41, and none of the fix's differences is new (each gives the same output asmain). They are indented# ...lines and comments on lines other thankey:lines.Other:
parse_frontmatter()over every.mdfile in this checkout (126 with frontmatter) gives the same result before and after, except that the two# SPDX-License-Identifier/# httpscomment lines no longer show up as keys. The CLI on the report from the issue: 3 violations and exit 1 onmain;OK (no violations)and exit 0 with the fix.Other:
tools/dev/check-family-plugins.pypasses; the tool has no plugin copy.RFC-AI-0004 compliance
None of the principles apply: a parsing fix in an offline, read-only validator, with no new access, mutation or outbound message.
Linked issues
Closes #2391
Notes for reviewers (optional)
dependencies = []) rather than adding a YAML dependency, and copies the comment rule from fix(spec-status-index): drop inline comments from frontmatter values #2344 rather than importingspec_status_index.# ...lines and comments on continuation lines are still read as before, because inside a|or>block scalar they are content and telling the two apart needs block-indentation parsing. A column-0 comment after a value like"closed" trailing text(not valid YAML) is also kept as onmain. Quoted values keep their quotes as before (profile: "asf"is still an invalid profile).date:) already passed onmain; with this changedate: # YYYY-MM-DDis read as empty too and passes the same way, instead of being reported as an invalid date. Flagging empty required values is a separate concern.tools/pilot-report-validator/entry intools/spec-loop/specs/meta-and-quality-tooling.mdgets one sentence on the comment rule, and the tool README says the same.docs/pilot-report-template.mdcannot be found.Generative AI was used: Codex wrote the change and the tests, and Claude Code reviewed them, ran the checks and drafted this description.
Generated-by: Codex (gpt-5.6-sol)