Skip to content

fix(git): git output the code parses is read NUL-separated, and git outcomes come from exit codes #1440

Closed

Description

@dan-petty

Problem

Lines cited at 05e9388 (release/v0.2.29).

#1952 deleted the release branch detection in commands/pr.py and the release commit step in commands/release.py, so this item does not change them now.

Several modules parse git's human-format listings, in which git C-quotes any path with non-ASCII or special bytes (core.quotePath), prints renames as old -> new, and translates messages. Reproduced with real git in scratch repositories:

  • Drift paths lose their first character. argo/gitops.py:267-276 strips the whole git status --porcelain output before splitting it. That removes the leading space of a first M entry, and _parse_drift_event (:228-233) then takes line[3:], so M k8s/app.yaml is reported as 8s/app.yaml. A rename yields k8s/app.yaml -> "k8s/app two.yaml", and a non-ASCII name yields k8s/caf\303\251.yaml. Each path is also resolved against the process's working directory, although porcelain paths are relative to the repository root.
  • Files drop out of review file lists. core/repo.py:361-396 reads git ls-files --cached --others --exclude-standard without -z. café.py is listed as "caf\303\251.py", is_file() is false, and the file is silently skipped by every caller of list_repo_files.
  • Test selection and refinement context. commands/test_cmd.py:50-67 splits git diff --name-only and git status --porcelain lines by hand (" -> ", strip('"')). roadmap/refine.py:257 and :280 read git ls-tree -r --name-only without -z, so the later read of a quoted ADR or source path fails.
  • core/cleanup.py:80 reads git worktree list --porcelain without -z.

The codebase already reads git NUL-separated elsewhere: git/operations.py:380-414 (diff --name-status -z with _parse_name_status), :321 (ls-tree -z) and core/cleanup.py:148 (ls-files -z).

Proposed remedy

  • Read every path listing NUL-separated and split on "\0": ls-files -z, status --porcelain=v1 -z (a rename's original path is its own field), diff --name-only -z or list_changed_files, ls-tree -z and worktree list --porcelain -z. Resolve status paths against the repository root.

Acceptance criteria

  • Real-git tests in temporary repositories whose status has a first entry M, a path with a space, a non-ASCII path and a rename. Drift events, list_repo_files, test selection and refinement context name exactly those paths.
  • Every new test runs in under 1 s and opens no socket; uv run devops ci passes.

Related: #1107, #1333, #1399.

Found by the 2026-10-08 client-library audit.

Opened as a borrow (#1153, budget/borrowed): the agent filing quota is spent for this cycle, and this is a defect or security finding of the owner-requested 2026-10-08 client-library audit.

Activity

  1. added
    type/bug
    scope/cli
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. Causes silent data loss (dropped files, mangled paths) and locale-dependent release failures across several workflows, but the system still runs and the bugs are edge-case-triggered rather than total outages.
    • Value: High. Drift detection, file listing, test selection, release-branch detection, and the release commit step all produce wrong or missing results for non-ASCII paths, renames, and non-English locales.
    • Effort: Medium. The fix is well-scoped (add -z flags, split on NUL, use exit codes) and the codebase already has the pattern in git/operations.py, but it touches six modules and requires new real-git tests.
  3. changed the title [-]fix(git): git output the code parses is read NUL-separated, and git outcomes come from exit codes[/-] [+]fix(git): git output the code parses is read null-separated, and git outcomes come from exit codes[/+] on Oct 25, 2026
  4. changed the title [-]fix(git): git output the code parses is read null-separated, and git outcomes come from exit codes[/-] [+]fix(git): git output the code parses is read NUL-separated, and git outcomes come from exit codes[/+] on Oct 25, 2026
  5. added a commit that references this issue on Oct 25, 2026
    37f159f
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

    scope/clisource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions