Skip to content

fix(decision-records): flag strict-YAML hazards in front matter - #7

Merged
trungfinity merged 1 commit into
mainfrom
fix/decision-records-front-matter-yaml
Jul 3, 2026
Merged

trungfinity merged 1 commit into
mainfrom
fix/decision-records-front-matter-yaml

Conversation

@trungfinity

Copy link
Copy Markdown
Contributor

Problem

parse_front_matter is deliberately tolerant (line-based, first-: split), so it accepts front matter that a spec-compliant YAML parser rejects. The sharp edge: an unquoted : inside a plain scalar starts a nested mapping in real YAML, which is illegal mid-value. GitHub's front-matter renderer uses a strict parser, so an affected record displays an error banner instead of rendering — hit in practice by skymavis/lanh-ai's 0009, whose summary contained …two modes: channel mode… ("Error in user YAML: mapping values are not allowed in this context").

Fix

New front_matter_errors() wired into check: for every record and draft, plain-scalar values containing : (or ending with :) are reported as errors, as are unbalanced opening quotes. Quoted values, flow sequences ([...]), null/empty, and folded/literal block scalars are exempt — block-scalar bodies are skipped by indent, mirroring the parser.

Deliberately narrow: this targets the one hazard class with a public failure surface, not full YAML validation — no new dependency.

Testing

  • 4 new tests: unquoted colon fails with the expected message; the same colon quoted passes; the same colon in a folded block scalar passes; an unbalanced quote fails.
  • Full suite: 66 passed.
  • Field-checked against skymavis/lanh-ai: the patched check flags 0009's original summary and passes its quoted fix (skymavis/lanh-ai#19).

The tolerant line-based parser accepts values a spec-compliant YAML
parser rejects — chiefly an unquoted ': ' inside a plain scalar,
which YAML reads as a nested mapping and errors on. GitHub's
front-matter renderer uses a strict parser, so such a record renders
as an error banner on github.com (hit in practice by a summary
containing 'two modes: channel mode').

check now reports front-matter values that are plain scalars
containing ': ' (or ending with ':'), and unbalanced quotes; quoted
values, flow sequences, and block scalars stay exempt.
@trungfinity
trungfinity merged commit eeb74cb into main Jul 3, 2026
5 checks passed
@trungfinity
trungfinity deleted the fix/decision-records-front-matter-yaml branch July 3, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant