Skip to content

fix(pr-management): handle missing .gitattributes in stack review - #2037

Merged
potiuk merged 3 commits into
apache:mainfrom
MakerFlyFly:fix/stack-ledger-missing-gitattributes-upstream
Nov 10, 2026
Merged

potiuk merged 3 commits into
apache:mainfrom
MakerFlyFly:fix/stack-ledger-missing-gitattributes-upstream

Conversation

@MakerFlyFly

Copy link
Copy Markdown
Contributor

Summary

  • Build the stack-review ledger when the target checkout lacks a root .gitattributes, so Step 3 can read it.
  • Report a missing parent on an explicit attributes path once on stderr. Keep the fallback ledger available and regenerate the packaged tool.

Type of change

  • Python package

Test plan

Verified e3e8182f against 0e0c0a62.

  • Reproduced FileNotFoundError, an empty ledger, and the downstream JSON error on the base. With the patch, an existing directory without the file yields byte-identical stdout to omitting the option and empty stderr.
  • On Windows and Linux, a missing parent yields one diagnostic with the same JSON and exit status. In a two-layer repro, correcting the path restores the major generated-file duplicate finding.
  • Windows and Linux stack_review each passed 92 tests and 15 subtests. Linux pr-management passed 805 tests and 15 subtests. Ruff, formatting, and mypy passed.
  • Whole-tree non-test prek, range-selected workspace-pytest, git diff --check, and packaged-source consistency passed.

Linked issues

Closes #2036

Generative AI disclosure

AI-assisted with Codex (GPT-6) for the implementation, tests, reproduction, and drafting. The contributor reviewed the final patch. All three commits carry Generated-by: trailers.

Stack review passes the target checkout's .gitattributes path on every
run. Some checkouts lack the file, which aborts ledger creation and
leaves the findings step with empty input.

Treat a missing attributes file as an empty source of generated-file
patterns. Exercise the CLI against the omitted-option control and
regenerate the packaged tool.

Generated-by: Codex (GPT-6)
Exercise malformed UTF-8 and a directory passed as the optional
attributes source. Check that a missing layer still identifies the
required diff when the attributes file is also missing.

Generated-by: Codex (GPT-6)
A mistyped clone path can drop the only rule identifying a file as
generated, which hides duplicate findings across layers. Diagnose
that case on stderr while producing the fallback ledger.

Cover the missing parent and the quiet fallback for an existing clone
with CLI regressions.

Generated-by: Codex (GPT-6)
@github-actions github-actions Bot added family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers labels Nov 9, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treating a missing root .gitattributes as "no extra generated-file patterns" fixes the empty-ledger failure for clones without one, while only FileNotFoundError is caught so real read errors still surface, and the CLI tests pin the quiet fallback, the wrong-path warning and the error paths.


This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Magpie handles maintainer review:
Contributing guide.

@potiuk
potiuk merged commit 17cbc11 into apache:main Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants