Skip to content

scripts/repo_shape.py: load_yaml names the file with {path} as it was typed in its three refusals, so a bidi control, an ESC or a line feed in a --plan, --root or --policy path reaches the terminal, where shown_path and _shown spell one (see #1152, #1115) #1168

Closed

Description

@brettheap

(lane openRepoShape-4, 2026-10-22T17:34:03Z)

Found by: W1152, lane 4's writer for #1152, while spelling the --plan path in check and execute. #1152 and #1115 (PR #1154) spell, with _shown, the paths that adopt-project.py prints itself. The refusals of repo_shape.load_yaml carry the path from inside scripts/repo_shape.py, so adopt-project.py cannot spell them where it prints its own lines. F3 then read the callers and probed the rest. Line numbers are approximate, at 038dafba9 (current origin/main).

State

load_yaml (scripts/repo_shape.py, about :1321) names the file in three refusals with the bare {path}:

  • yaml-unreadable, f"{path}: cannot be read ({_os_reason(exc)})" (about :1342);
  • yaml-unreadable, f"{path}: not UTF-8 at byte {exc.start} ({exc.reason})" (about :1346);
  • yaml-unparsable, f"{path}: {where}{exc}" (about :1359).

The same file already names a path with shown_path (about :3274) in the details beside these: git-failed (about :1402), not-a-git-repo (about :3583, #919) and the link manifest's why (about :3352, #610). load_yaml is the one that does not.

What happens

Probe (F3, 038dafba9; a stub gh first on PATH, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, an empty global git config): adopt-project.py check --plan <D>/pl<U+202E>an.yaml, over a file whose text is not YAML. Stderr, exit 2:

REFUSED yaml-unparsable: <D>/pl<U+202E>an.yaml: line 2: empty keys are not supported

The U+202E itself is in that line: nothing spelled it. The other two refusals do the same with the path raw: a missing file says cannot be read (No such file or directory), and a file that is not UTF-8 says not UTF-8 at byte 8 (invalid start byte). An ESC in the path reaches stderr as the ESC (probed with a directory in the plan's place: cannot be read (Is a directory)), and a line feed splits the line in two (probed with the unparsable file).

Which tools

load_yaml is called with a path the person typed, or one built from a typed --root, by these. "Probed" is a real run with U+202E in the typed path, and the output held it raw.

tool typed value load_yaml call
adopt-project.py check, execute --plan <file> Plan.load, about :6507, called at about :12709 and :15338. check probed; execute by reading
adopt-project.py plan --path-policy <file> PathPolicy.load, scripts/path_classify.py about :183. Probed
scripts/validate-repository-naming.py --policy <file>, --project <file> NamingPolicy.load (repo_shape.py about :2233) called at about :1455; _project_manifest about :1138. Both probed
scripts/bump-leg.py --root <dir>, then <dir>/project.yaml Project.open, about :234. Probed
scripts/family.py (add, bump, remove) --family-root <dir>, then <dir>/family.yaml Family.open, about :563, called at about :7476, :9323 and :10174. bump probed
update-shape.py --root <dir>, then <dir>/contracts/shape-pin.yaml _read_yaml, about :794. check probed
templates/assembly-root/scripts/validate-manifest.py --root <dir>, then <dir>/project.yaml _load, about :205. Probed, as a root carries the script

Not raw, so not part of this: templates/assembly-root/scripts/validate-pins.py (its _load, about :595, rewrites load_yaml's leading <path>: as the root-relative name: probed, it says REFUSED yaml-unparsable: project.yaml: line 2: ...), and the manifest row of shape-doctor.py (it writes the character as ?: probed). setup-project.py (about :2228) and the doctor's _read swallow the refusal.

Not probed: templates/assembly-root/scripts/bootstrap.py (about :483, :1792, :1930), templates/family-root/scripts/bootstrap.py (about :1900), siblings.py (about :590, :776, :1560), validate-family.py (about :1581, :1623, :4208) and scripts/shape_advisory.py (about :637). By reading, each calls load_yaml on <root>/<a fixed name> of a root it was given, so they probably show the same.

The same raw path stands one line after load_yaml in the loaders above, where the file is not a mapping (read, not probed): plan-unreadable (adopt-project.py about :6509), path-policy-unreadable (path_classify.py about :185), policy-unreadable (repo_shape.py about :2235), bump-leg-manifest-unreadable (bump-leg.py about :236) and manifest-unreadable (validate-repository-naming.py about :1140). The adopt-project.py one belongs with #1152's {plan.path}: ... refusals.

What to spell it with

In load_yaml: shown_path(path) at the three sites. It is in the same module (no new import), it is what the other details of the file already use (#610, #919), and a path whose every character is printable prints byte for byte as it does now. A path with a character that is not printable prints as Python's repr, quotes and all ('<D>/pl\u202ean.yaml', \x1b, \n, and \udcff for a byte that is not UTF-8). So a check run would write the plan path in two styles: repr from load_yaml, and _shown's backticks in adopt-project.py's own lines. That is a difference of style, not a hole. adopt-project.py's own {path}: not a mapping (plan-unreadable) takes _shown(str(path)), as #1152 does for plan.path.

The cost. scripts/repo_shape.py is a shape copy: every assembly root carries one (templates/assembly-root/README.md about :160 lists it) and so does every family holder (scripts/family.py about :10266 runs "the holder's own repo_shape.py"). update-shape.py says so in its own words (about :315-320): it "is a shape copy, and a helper there would be an upstream-changed row in every project". #827 and #919 (PR #952) each changed this file in the same way and re-pinned every root. So update-shape.py check shows scripts/repo_shape.py as upstream-changed in every project until apply re-copies it and re-pins. Whether a terminal-hygiene change is worth that, or should ride with the next change to the file, is the lane's ruling.

An alternative that leaves the copy alone. Spell at the call site, as repo_shape.py does at about :3359 for a --link-source manifest (exc.detail.replace(str(path), named)) and family.py at about :1125: the callers in adopt-project.py (Plan.load's two, and PathPolicy.load's) re-raise the refusal with _shown(str(path)) for str(path). That covers adopt-project.py, which is #1152's concern, and leaves the other five tools raw. Recommended: the change in load_yaml, since one change covers all six tools that are raw (adopt-project.py, validate-repository-naming.py, bump-leg.py, family.py, update-shape.py and validate-manifest.py); the call-site route is for the case that the re-pin is refused.

What a change in load_yaml must keep working. Readers that find the path in the detail by its text:

  • templates/assembly-root/scripts/validate-pins.py's _load (about :613) tests exc.detail.startswith(f"{path}: ") and then writes the root-relative name. Once load_yaml spells a path that is not printable, that test fails, and the run would print the absolute spelled path in place of the relative one. This is for a root whose own path holds a control character only; the line stays spelled. It needs a row.
  • repo_shape.py about :3359 and family.py about :1125 call exc.detail.replace(str(path), ...). The first already holds the same spelling; the second names a throwaway clone's temporary directory, which is printable. Neither changes, and each wants a row that says so.

Rows

In tests/test_load_yaml_refusals.py: each of the three refusals with U+202E, ESC and a line feed in the path, in process. Then one row through each tool in the table (a real run, as the probe above), and the validate-pins.py row.

See #1152 and #1115 (PR #1154), and #610, #919 and #827 for the helpers and the re-pin.

Lane: openreposhape-4 (openRepoShape-4)

Activity

  1. added this to the v1.2.1 milestone on Oct 23, 2026
  2. brettheap commented on Nov 8, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-5, session 50cede29-ab82-4ca3-9f67-d98e1a58c8d2@Eagle, 2026-11-08T18:29:02Z, for #1168

    Logged in lanes/log/openRepoShape-5.md at d22cb29dac2926956e13831665546455e3811f30.

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

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1168:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1168"`, kept where the row or its body names `#1168`:
    1177	adopt-project.py: the `--plan` path in `check` and `execute`, and the `--local-remote-dir` path in `execute`'s `bare`, leg and `split` lines, are named with `_shown`, as #1154 names `--out` and `--work-dir`, so a bidi control, an escape, a line feed or a byte that is not UTF-8 in either no longer reaches the terminal as it was typed (#1152)	fix/1152-plan-and-remote-paths-spelled	OPEN
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1168` as a whole token:
       none
    
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