Skip to content

fix(pilot-report-validator): ignore YAML comments in frontmatter - #2392

Open
leninworld wants to merge 1 commit into
apache:mainfrom
leninworld:fix/pilot-report-validator-yaml-comments
Open

leninworld wants to merge 1 commit into
apache:mainfrom
leninworld:fix/pilot-report-validator-yaml-comments

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

This PR fixes issue #2391.

Summary

  • pilot-report-validator read YAML # comments in a report's frontmatter as values, although docs/pilot-report-template.md itself has # comment lines there. A column-0 # ... line was appended to the previous key's value (date: 2026-06-29 followed 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), and profile: asf # asf | non-asf | custom was 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 a key: line with the rule spec-status-index got 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, so notes: | # x is still a block scalar. All other lines are read as before.

Type of change

  • Python package (tools/*/ with pyproject.toml)
  • Documentation (docs/, README.md, CONTRIBUTING.md)

Test plan

  • prek run --all-files passes: prek run --all-files --skip workspace-pytest passes, and prek run workspace-pytest --from-ref origin/main --to-ref HEAD passes.

  • For Python packages touched: uv run pytest / ruff check / mypy passes: tools/pilot-report-validator 78 passed; ruff check, ruff format --check and mypy are clean.

  • Other: new tests in tools/pilot-report-validator/tests/test_pilot_report_validator.py. On main (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 after date: and profile:. Guard cases pass on main and 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 on main and 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: main differs on 207, the fix on 41, and none of the fix's differences is new (each gives the same output as main). They are indented # ... lines and comments on lines other than key: lines.

  • Other: parse_frontmatter() over every .md file in this checkout (126 with frontmatter) gives the same result before and after, except that the two # SPDX-License-Identifier / # https comment lines no longer show up as keys. The CLI on the report from the issue: 3 violations and exit 1 on main; OK (no violations) and exit 0 with the fix.

  • Other: tools/dev/check-family-plugins.py passes; 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)

  • This keeps the tool's stdlib-only line reader (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 importing spec_status_index.
  • Left unchanged: indented # ... 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 on main. Quoted values keep their quotes as before (profile: "asf" is still an invalid profile).
  • Not changed here: a required key whose value is empty (date:) already passed on main; with this change date: # YYYY-MM-DD is 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.
  • Spec sync: the tools/pilot-report-validator/ entry in tools/spec-loop/specs/meta-and-quality-tooling.md gets one sentence on the comment rule, and the tool README says the same.
  • The template smoke tests now fail, instead of skipping, if docs/pilot-report-template.md cannot 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)

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)
@github-actions github-actions Bot added family:tools tools/* family:docs Docs, MISSION.md, READMEs substrate:framework-dev Tool substrate: build / validate / eval the framework itself family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json labels Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:dev Repo dev: .asf.yaml, spec-loop specs, Node manifests, .claude/settings.json family:docs Docs, MISSION.md, READMEs family:tools tools/* substrate:framework-dev Tool substrate: build / validate / eval the framework itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pilot-report-validator reads YAML comments in the frontmatter as values

1 participant