From d32da5a4e5d9c74d4e47fff77ba4007cd62141a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 25 Aug 2026 18:32:39 +0000 Subject: [PATCH] fix(branch_archive): stop checkout's persisted credential hijacking the push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_01KwqicJpMqmcT5RVbyNwdKq --- .github/workflows/branch_archive.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/branch_archive.yml b/.github/workflows/branch_archive.yml index 93a4bcb7..5903f2b2 100644 --- a/.github/workflows/branch_archive.yml +++ b/.github/workflows/branch_archive.yml @@ -78,6 +78,15 @@ jobs: repository: ${{ github.repository_owner }}/PyAutoGut path: .gut fetch-depth: 1 + # Load-bearing. With the default (true), checkout writes an + # `http.https://github.com/.extraheader` auth header into this + # clone's config, and that header WINS over credentials embedded in + # a remote URL. The archive push then goes out as + # github-actions[bot] — which has no access to a sibling repo — and + # fails 403 no matter what `git remote set-url` was told. Leaving it + # on cost one run to discover; the dry run caught it before any + # delete, which is the only reason that was cheap. + persist-credentials: false - uses: actions/setup-python@v5 with: @@ -134,6 +143,13 @@ jobs: echo "::endgroup::" echo "::group::Archive into the Gut" + # Confirm no inherited credential is about to hijack the push. An + # extraheader here means the archive would go out as the workflow + # identity instead of the PAT — the 403 that cost run #1. + if git config --local --get-regexp 'http\..*\.extraheader' >/dev/null 2>&1; then + echo "::error::the Gut checkout carries a persisted credential; it would override the PAT." + exit 1 + fi # The Gut owns its own namespace and its own refusal-to-overwrite. PYAUTO_GUT_REMOTE=origin bin/pyauto-gut archive __to_archive__ "$name" echo "::endgroup::"