Skip to content

repo_shape.py's YAML reader: a key written twice keeps the last without a word, and a block-scalar line indented less than its block loses its first characters #917

Closed

Description

@brettheap

Goal: scripts/repo_shape.py's YAML reader refuses, by line, a key written twice and a block-scalar line indented less than its block, instead of reading either silently.

Filed by lane openRepoShape-3, from its triage of #459 at the v1.1.1 release commit 5017830. It groups #459's lines U021 (L2-4) and U181 (RV823's SHOULD-2), with U123 and U155 (L4-156, posted twice) as a section that is a documented limit, one pull request's worth. scripts/repo_shape.py is a pinned copy, so the change re-pins every project once.

A key written twice keeps the last (U021)

State. The block mapping builder assigns out[key] = ... at scripts/repo_shape.py:1052, :1061 and :1063, and the flow builder at :724, with no check for a key already there. Brett Heap ruled on 2026-10-14: refuse a duplicated key (backlog). v1.0.0's notes list it as a known limit (docs/release-notes/v1.0.0.md:468).

What happens. Measured in process at 5017830:

parse_yaml("a: 1\na: 2\n")        -> {'a': 2}
parse_yaml("k: {a: 1, a: 2}\n")   -> {'k': {'a': 2}}

A nested block reads the same. So a shape pin holding a valid files: list and then files: 5 reads as files: 5, and a doubled commit: or members: in any contract file passes.

Evidence. The lines and the probe above.

Direction. In the block and flow mapping builders, raise YamlError with "line N: key 'k' is written twice" when the key is already in out. Test rows for block, flow and nested.

An under-indented block-scalar line loses text (U181)

State. _block_scalar_body appends nxt[block_indent:] for each body line (scripts/repo_shape.py:910-914), with no check for a line indented less than block_indent.

What happens. Measured in process at 5017830:

parse_yaml("k: |\n    a\n  bcd\n    e\n")   -> {'k': 'a\nd\ne\n'}

bc is dropped without a word. PyYAML refuses the document.

Evidence. The line and the probe above; RV823 measured it on #823's head 153bab90.

Direction. Refuse a non-blank body line indented less than the block, by line, as the reader's other refusals do, with a row in tests/test_yaml_reader_spaces.py.

Documented limit (v1.1.0.md:749-751), needs a ruling to reopen (U123, U155)

State. The reader is a subset by design, and v1.1.0's notes keep this list as a known limit (docs/release-notes/v1.1.0.md:749-751, #459's L4-156). #715's body: "Stays out of this issue: L4-156".

What happens. Measured in process at 5017830, each of these reads where PyYAML refuses it or reads another thing:

k: - a      -> {'k': '- a'}
k: [- ]     -> {'k': ['-']}
k: [e?]     -> {'k': ['e?']}
k: [|a]     -> {'k': ['|a']}
@a: 1       -> {'@a': 1}
k: [?a]     -> {'k': ['?a']}

Evidence. The probe above.

Direction (needs a ruling). Per construct, refuse it in the reader's existing words, or keep it and leave it documented. Nothing here is to be done without that ruling.

Size: S (the first two sections; M if the third is ruled in).

Lane: openreposhape-3 (openRepoShape-3)

Activity

  1. added this to the v1.2.0 milestone on Oct 18, 2026
  2. brettheap commented on Oct 18, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-18T16:11:24Z, for #917

    Logged in lanes/log/openRepoShape-3.md at 3f97b55e890e10c3e564a4108cc98d87de769adb.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#917:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#917"`, kept where the row or its body names `#917`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `917` as a whole token:
       none
    
  3. brettheap commented on Oct 22, 2026

    @brettheap
    ContributorAuthor

    (lane openRepoShape-3, 2026-10-22T12:08:46Z) Ruling: U123 and U155 stay a documented limit, so #917 is done.

    Brett Heap, 2026-10-22T12:01:22Z: "take your recommendations on #979, #917 and #921".

    Lane: openreposhape-3 (openRepoShape-3)

  4. brettheap commented on Oct 22, 2026

    @brettheap
    ContributorAuthor

    RELEASED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-22T12:15:22Z, for #917 — done: U021 and U181 landed in #974; U123 and U155 stay documented on Brett Heap's ruling of 2026-10-22T12:01:22Z; #917 closed as completed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions