Skip to content

Fail Patch provenance with a message when git can't read - #9233

Merged
craigmichaelmartin merged 1 commit into
mainfrom
patch-provenance-fail-closed
Dec 4, 2026
Merged

craigmichaelmartin merged 1 commit into
mainfrom
patch-provenance-fail-closed

Conversation

@craigmichaelmartin

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Two follow-ups from the review of #9228:

  • When the check's git ls-remote or fetch failed, the job ended with a stack trace and no summary. It failed closed, but didn't say why.
  • hasFile read any git error as a missing path. A missing oclif manifest, for example, skips that file's version check, so a failed read of a tree has to fail the check, as a failed read of a file's text already does. With every commit and tree fetched that shouldn't happen, but the check shouldn't depend on it.

WHAT is this pull request doing?

  • A failed git ls-remote or fetch fails the check with git's message, for example "Fetching stable/5.2, the pull request and main failed: …", and writes the usual summary.
  • hasFile uses git ls-tree, which prints nothing for a missing path and fails on a failed read. A failed read fails the check with its message.
  • Both git ls-tree calls read paths literally (--literal-pathspecs), as git rev-parse <commit>:<path> did.

Nothing else changes. Checked locally: the 35 cases from earlier reviews give the same results and messages as the current file, with every gh call refused. Four new cases fail with a message: a failed read of a tree for a Version Packages bump that leaves both oclif manifests behind (the current file passes it), the same for a backport's changeset, and a failed fetch and ls-remote (the current file ends without a message). The same file goes to stable/5.2 in its own pull request.

How to manually test your changes?

Run the check against a repository that doesn't exist (needs git and Node):

mkdir /tmp/provenance && cd /tmp/provenance
curl -fsSL https://raw.githubusercontent.com/Shopify/cli/c250a1f23d792b17da187baedeee36832cea2d4d/.github/workflows/patch-provenance.yml \
  | sed -n "/cat > check.mjs <<'SCRIPT'/,/^ *SCRIPT$/p" | sed '1d;$d;s/^          //' > check.mjs
touch summary.md
GIT_TERMINAL_PROMPT=0 GITHUB_REPOSITORY=Shopify/no-such-repository GITHUB_STEP_SUMMARY=summary.md PR_NUMBER=1 \
  BASE_REF=stable/5.2 HEAD_REF=example HEAD_SHA=0123456789abcdef0123456789abcdef01234567 HEAD_REPO=Shopify/cli node check.mjs
cat summary.md

It fails at once with "Reading the head of stable/5.2 failed: remote: Repository not found. …", and the summary says the same. With the current file, the same command ends with a stack trace and an empty summary.

🤖 Generated with Claude Code

A failed git ls-remote or fetch fails the check with git's message and the usual summary, instead
of ending the job with a stack trace. hasFile reads trees with git ls-tree, which fails on a failed
read, so a failed read fails the check instead of reading as a missing path. Both git ls-tree calls
read paths literally, as git rev-parse <commit>:<path> did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@craigmichaelmartin
craigmichaelmartin requested a review from a team as a code owner December 4, 2026 19:46
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Dec 4, 2026
@craigmichaelmartin
craigmichaelmartin added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 0d3474b Dec 4, 2026
28 checks passed
@craigmichaelmartin
craigmichaelmartin deleted the patch-provenance-fail-closed branch December 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants