Skip to content

fix(branch_archive): stop checkout's persisted credential hijacking the push - #284

Merged
Jammy2211 merged 1 commit into
mainfrom
claude/repo-cleanup-82k6kh
Aug 25, 2026
Merged

fix(branch_archive): stop checkout's persisted credential hijacking the push#284
Jammy2211 merged 1 commit into
mainfrom
claude/repo-cleanup-82k6kh

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

What failed

The first real dispatch of branch_archive.yml (run 32884038271) reached the archive step and stopped:

PyAutoLabs/PyAutoHands@master = 55da101c... (442 commits)
remote: Permission to PyAutoLabs/PyAutoGut.git denied to github-actions[bot].
fatal: ... The requested URL returned error: 403

Note the identity: github-actions[bot], not the PAT.

actions/checkout defaults to persist-credentials: true, which writes an http.https://github.com/.extraheader auth header into the checkout's local config — and that header takes precedence over credentials embedded in a remote URL. So this line was silently overridden:

git remote set-url origin "https://x-access-token:${PAT}@github.com/${owner}/PyAutoGut.git"

and the push went out as the workflow identity, which has no access to a sibling repo.

Fix

  • persist-credentials: false on the Gut checkout, so nothing is inherited and the PAT in the remote URL is what authenticates.
  • An assertion immediately before the push that the clone carries no extraheader at all. This failure mode is silent by nature — the wrong credential still produces a plausible-looking push attempt — so the identity is checked rather than assumed.

The dry run is why this cost nothing

It was dispatched with delete_after: false precisely so the first exercise of an irreversible path could fail safely, and the ordering held: set -e aborted at the archive, far from the delete.

A first run with deletion enabled would also have been fine — a failed archive means no delete — but only because the design works, not because anyone had watched it work. Those are different things, and the difference is worth one run.

Checks

pytest tests/510 passed · repos_sync.py --check → all 12 green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq


Generated by Claude Code

…he push

The first real dispatch failed at the archive step:

  remote: Permission to PyAutoLabs/PyAutoGut.git denied to github-actions[bot].
  fatal: ... The requested URL returned error: 403

Note the identity: github-actions[bot], not the PAT. `actions/checkout`
defaults to persist-credentials: true, which writes an
`http.https://github.com/.extraheader` auth header into the checkout's local
config — and that header takes precedence over credentials embedded in a
remote URL. So `git remote set-url origin "https://x-access-token:$PAT@..."`
was silently overridden, and the push went out as the workflow identity, which
has no access to a sibling repo.

Two changes:

- persist-credentials: false on the Gut checkout, so nothing is inherited and
  the PAT in the remote URL is what authenticates.
- A check immediately before the push that the clone carries no extraheader at
  all. The failure mode is silent by nature — the wrong credential still
  produces a plausible-looking push attempt — so this asserts the identity
  rather than assuming it.

The dry run is why this cost nothing. It was dispatched with delete_after
false precisely so the first exercise of an irreversible path could fail
safely, and the ordering held: `set -e` aborted at the archive, far from the
delete. A first run with deletion enabled would have been fine too — the
archive failing means no delete — but only by the design working, not by
having tested it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq
@Jammy2211
Jammy2211 merged commit af1a439 into main Aug 25, 2026
2 checks passed
@github-actions
github-actions Bot deleted the claude/repo-cleanup-82k6kh branch August 25, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants