Skip to content

stack-review cannot build a ledger without a root .gitattributes #2036

Closed

Description

@MakerFlyFly

What's broken

pr-management-stack-review stops in Step 2 when the target checkout has no root .gitattributes. Step 3 then fails to load the empty ledger.

Which layer

Step 2 supplies the attributes path for every checkout. The ledger opens that path before reading the layer diffs. Step 2 command, ledger source.

How to reproduce

From a Magpie checkout at 0e0c0a62d67be2fca98a0b78e24e31524ba55094, run in Bash.

scratch=$(mktemp -d)
git init -q "$scratch/clone"
cat > "$scratch/1.diff" <<'DIFF'
diff --git a/a.py b/a.py
--- a/a.py
+++ b/a.py
@@ -1 +1 @@
-print("old")
+print("new")
DIFF

uv run --frozen --project tools/pr-management python -m pr_management.stack_review.stack_ledger \
  ledger --layer "1=$scratch/1.diff" --gitattributes "$scratch/clone/.gitattributes" > "$scratch/ledger.json"
printf 'ledger exit=%s, bytes=%s\n' "$?" "$(wc -c < "$scratch/ledger.json")"
uv run --frozen --project tools/pr-management pr-management stack-review findings \
  --no-fetch --ledger "$scratch/ledger.json"

Expected vs actual

Expected. The absent file contributes zero patterns. The ledger exits 0 with the same JSON as the omitted-option control, and findings reads it.

Actual. ledger exits 1 with FileNotFoundError and writes 0 bytes. findings exits 1 with JSONDecodeError. For the control, drop the --gitattributes option and its value, then rerun both commands.

Surface area (optional)

The fix belongs in the ledger CLI and its packaged copy. A readable attributes file contributes linguist-generated patterns. Directory and decoding errors still surface. A missing parent on an explicitly supplied attributes path warrants one stderr diagnostic before the fallback ledger is emitted.

Environment (optional)

Reproduced on Windows with Python 3.12.13 and Linux with Python 3.12.12, both with uv 0.11.14.

Generative AI disclosure. AI-assisted with Codex (GPT-6) for reproduction and drafting.

Activity

  1. added
    bug
    on Nov 9, 2026
  2. added
    substrate:analytics
    on Nov 10, 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

    bugfamily:toolssubstrate:analytics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions