Repository navigation
Description
Lane: openreposhape-5 (openRepoShape-5)
Found by this lane's adversarial review of #213's fix (F1 and N5), where PR #244's body leaves it out for a follow-up issue. Pre-existing on main 54aa69a. Latent: every writer in this repository closes the quote it opens, so this is a reader that guesses where its header says it "raises rather than guessing", not a live failure.
What is wrong. _scalar (scripts/repo_shape.py:278) decides a scalar is quoted by looking only at its first and last characters: text[0] == '"' and text[-1] == '"' (:285) or the same with ' (:283). It never asks whether the last quote CLOSES the scalar that the first one opened. So an unterminated double-quoted scalar is not recognised as quoted at all and is read as the plain text, quote and all, or, when its last character happens to be an escaped ", it is read as quoted and the backslash survives. And a quoted scalar followed by more text is read as one scalar when the text ends in a quote. PyYAML 6.0.3 refuses every row below, and so should the reader.
SHAPE=<openRepoShape checkout>
SHAPE=$SHAPE python3 - <<'PY'
import os, sys
sys.path.insert(0, os.environ["SHAPE"] + "/scripts")
from repo_shape import parse_yaml, YamlError
def read(text):
try:
return repr(parse_yaml(text))
except YamlError as exc:
return f"YamlError: {exc}"
# every one of these is invalid YAML: PyYAML 6.0.3 refuses it
for text in ('created_by: "Brett Heap\n', # the closing quote is missing
'k: "abc\n',
'k:\n - "a\\"\n', # the only quote that could close it is escaped
'k: "a\\", b\n',
'k: "a" b "c"\n', # text after the closing quote
'k: "a"b\n',
"k: 'abc\n",
"k: 'a' b 'c'\n",
'k: ["a\\", b]\n', # the same, in a flow sequence
'k: ["a, b]\n'):
print(f"{text!r:30} ->", read(text))
PYObserved on main 54aa69a:
'created_by: "Brett Heap\n' -> {'created_by': '"Brett Heap'}
'k: "abc\n' -> {'k': '"abc'}
'k:\n - "a\\"\n' -> {'k': ['a\\']}
'k: "a\\", b\n' -> {'k': '"a\\", b'}
'k: "a" b "c"\n' -> {'k': 'a" b "c'}
'k: "a"b\n' -> {'k': '"a"b'}
"k: 'abc\n" -> {'k': "'abc"}
"k: 'a' b 'c'\n" -> {'k': "a' b 'c"}
'k: ["a\\", b]\n' -> {'k': ['a\\', 'b']}
'k: ["a, b]\n' -> {'k': ['"a, b']}
On fix/yaml-flow-escaped-quote 86ffe66 (PR #244) every row is the same except the flow row k: ["a\", b], which now reads ['"a\\", b'], the way its block twin k:\n - "a\", b reads: #244 makes the flow and block reads agree, and they agree on the wrong answer.
Row 1 is the one a person meets: a missing closing quote on a hand-edited created_by, reference or plan path is not refused; the value carries a leading " into every validator that reads it. Row 3 reads a\, a value with a backslash that no YAML reader would produce. Rows 5 and 6 read as one scalar, or as plain text, where YAML ends the scalar at the closing quote and refuses what follows.
Expected. A scalar that begins with a quote is ONE complete quoted scalar or the reader raises YamlError by name: no closing quote (a " closes only when no backslash escapes it; a ' closes at a ' not doubled), or text after the closing quote other than a comment, is a refusal, in a block, a flow item and a key alike. The reader's header already promises this ("raising rather than guessing"). The fix needs its own differential check: the 14 tracked YAML files read as before, the plan round-trip tests, and the review's flow-against-block fuzz.
Reach. Writers cannot emit it: y() (adopt-project.py:223) closes every quote it opens, and the templates quote free text with a closing quote (templates/assembly-root/project.yaml:32,42,46). So it shows only on a file a person edits or another tool writes. The review of #244 put a number on the neighbourhood: of 607,073 raw documents PyYAML refuses, 264 read differently on #244 than on main, and 12 that main refused are now read silently (k: ["\",[] reads ['"\\",[']). All are invalid YAML.
Found by. handoffs/openRepoShape/attachments/lane-openRepoShape-5/review213-report.md in opensoft/brett-wip (F1 and N5; the PR body's "Left out" says "left for a follow-up issue"). Re-run on main 54aa69a and on 86ffe66 for this issue.
Not claimed.
🤖 Generated with Claude Code
Activity
brettheap commentedon Oct 11, 2026
CLAIMED — lane openRepoShape-5, session e62c2fd7-176d-429d-89fb-0653dd08ad5f@Eagle, 2026-10-11T21:45:07Z, for #250
Logged in
lanes/log/openRepoShape-5.mdatbf576a3a675d7258067f9012ce6fed11f9ee9f69.The three reads (lane-collision-protocol Rule 1):
scripts/repo_shape.py: a block scalar's record carries its key and it…
scaffold-project.py: a `--referent-chain` link between the first and …
Merge origin/main (eb6df75) into fix/yaml-quote-boundaries (#249, #250)
fix round 1 (#249, #250): a `[` or `{` later in a key, before its `: …
Merge origin/main (c3f4987) into fix/yaml-quote-boundaries (#249, #250)
Merge origin/main (5751460) into fix/yaml-quote-boundaries (#249, #250)
Merge origin/main (60588d5) into fix/yaml-quote-boundaries (#249, #250)
tests/test_adopt_template_values.py: the valid-elector control reads …
Merge origin/main b30595c into fix/adopt-root-kept-symlinks: #207, #272…
Merge origin/main (6d8d88b: #249 and #250 via #284, #204 via #227, #203…
Merge origin/main (b30595c) into fix/adopt-late-failure-notice
Merge origin/main (b421e6b) into fix/adopt-template-values-utf8: #231'…
Merge origin/main ede15ce into fix/adopt-relative-submodule-url: #215, …