Skip to content

shape-doctor.py submodule_config reads a family holder's .gitmodules through git_out, which decodes strictly, inside except (Refusal, OSError), so a member url that is not UTF-8 raises a UnicodeDecodeError that run_checks does not catch and shape-doctor.py --root ends in a traceback, exit 1 (also the code of a finding), with no verdict, where validate-family.py and siblings.py read the same file as bytes or with errors="replace" #432

Closed

Description

@brettheap

(lane openRepoShape-2, 2026-10-12T17:31Z)

Found by this lane's review of PR #404 (the fix for #385) at f9d420a: it moves the members row's reads of the origin URL to bytes and found the doctor's read of the holder's .gitmodules url still strict. #385 names shape_advisory.repository_names, origin_url and origin_name; none covers this read. The same on main and at #404's head. Reproduced on origin/main 92e29d9 (git 2.43.0, Python 3.12.3), local remotes only, a stub gh. Not claimed.

What is wrong. For a family holder, the doctor's members row asks where each member is mounted from (mounted_from, shape-doctor.py:3334, reached from member_state, :3481, check_members, :3637). The answer is read out of the holder's .gitmodules by submodule_config (:3282): git config -f .gitmodules --get-regexp '^submodule\..*\.(path|url)$' through git_out, which decodes strictly (scripts/repo_shape.py:843), inside try ... except (Refusal, OSError) (:3291-3295). A member url that is not UTF-8 (a mount from a local path under a directory named in a legacy code page, a hand-edited .gitmodules) raises UnicodeDecodeError, which is neither: it is a ValueError, run_checks (:4281) catches Refusal and OSError only, and --root ends in a traceback, exit 1, with no verdict. The holder's own gate and the siblings tool read the same file in ways that survive it (validate-family.py:680 asks with binary=True; siblings.py:171-173 decodes with errors="replace"), so the doctor is the outlier.

# $U: a checkout of openRepoShape at 92e29d9. $H: a family holder with one member, made by `family.py init` and `family.py add --member testorg/Atlas --local-remote-dir "$D/remotes"` (local). Local; no network.
python3 "$U/shape-doctor.py" --root "$H"                       # COMPLIANT   (exit 0)
git config -f "$H/.gitmodules" submodule.members/Atlas.url "$D/remotes/$(printf 'caf\xe9')/Atlas.git"
python3 "$U/shape-doctor.py" --root "$H"
#   exit 1
#   Traceback: shape-doctor.py line 4601 in main / 4287 run_checks / 3670 check_members / 3481 member_state / 3334 mounted_from / 3292 submodule_config -> repo_shape.py line 843, git_out
#   UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 188: invalid continuation byte
the member's url in the holder's .gitmodules shape-doctor.py --root
<dir>/Atlas.git (control) COMPLIANT, exit 0
<dir>/café/Atlas.git (UTF-8) COMPLIANT, exit 0
<dir>/caf<e9>/Atlas.git exit 1, UnicodeDecodeError traceback from submodule_config; no verdict, no rows

What it should do. Read the config as bytes (binary=True) and decode with errors="surrogateescape" or "replace" for the comparison: the url is compared with the member's other remotes (mounted_from hands it to resolved_remote, then same_repository), and a url that is not text matches nothing, which is the answer the row already gives for a relative url with no remote to resolve it against. Either way the row says what it found and the run reaches a verdict. A traceback is never the answer: exit 1 is also the code of a finding, so a script cannot tell this crash from INVALID.

How to test. In tests/test_shape_doctor.py's family harness: a holder with a mounted member and a .gitmodules url written with write_bytes containing \xe9 (POSIX; skip where the filesystem cannot hold the byte): --root and --json exit with a verdict (not a traceback), the members row names the member, and the same holder with an ASCII url still answers COMPLIANT. The unit submodule_config(root) returns the section with the url kept as text it can compare.

Not in this issue. The origin URL reads (#385, PR #404). family.py's own .gitmodules reads (_git_bytes, already bytes).

Related: #385 and PR #404 (the neighbouring reads, and the review that found this one); #292 and PR #353 (adopt's strict reads).

Lane: openreposhape-2 (openRepoShape-2)

Activity

  1. added this to the v1.1.0 milestone on Oct 15, 2026
  2. brettheap commented on Oct 15, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-4, session 11c6c0ef-495a-4a05-94cf-811b7b0a1012@Eagle, 2026-10-15T23:02:33Z, for #432

    Logged in lanes/log/openRepoShape-4.md at 99f052dfc18fd09b3bc2947adb72d21b946fe88e.

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

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#432:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#432"`, kept where the row or its body names `#432`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `432` as a whole token:
       none
    
  3. added a commit that references this issue on Oct 16, 2026
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