Skip to content

BUG: generate_git_patch reports an unauthenticated promisor blob-fetch failure as "Branch 'X' does not exist locally" #52153

Description

@sg650

Summary

create_pull_request regressed between v0.85.4 and v0.86.1/0.86.2. generate_git_patch Strategy 1 now performs a network branch-existence check after it has already computed the merge-base and enumerated the commits on that branch. In a workflow whose checkout uses persist-credentials: false (gh-aw's own default) that call fails authentication, the failure is reported as "Branch 'X' does not exist locally", and patch generation aborts — so the agent commits a working change and then cannot open a PR.

On a blobless (--filter=blob:none) working copy the same call also surfaces as fatal: could not fetch <sha> from promisor remote.

A/B evidence

Same repository, same workflow source, same inputs, same custom git fetch --filter=blob:none step, 26 minutes apart. The only variable is the gh-aw version.

v0.85.4 — success. Strategy 1 completes 8 ms after enumerating commits; no network access:

[generate_git_patch] Strategy 1: Using pinned SHA <sha> (branch: agent-fix/example)
[generate_git_patch] Strategy 1 (full): Computing merge-base with main (ignoring any stale origin/agent-fix/example)
[generate_git_patch] Strategy 1 (full): origin/main exists locally
[generate_git_patch] Strategy 1 (full): Computed merge-base: <sha>
[generate_git_patch] Strategy 1: Resolved baseRef <sha> to SHA <sha>
[generate_git_patch] Strategy 1: Found 1 commits between <sha> and <sha>
[generate_git_patch] Strategy 1: SUCCESS - Generated patch with 111 lines
[generate_git_patch] Final: SUCCESS - patchSize=4750 bytes, patchLines=111

v0.86.2 — failure. Identical trace, then a ~670 ms network round trip that fails auth:

[generate_git_patch] Strategy 1: Using pinned SHA <sha> (branch: agent-fix/example)
[generate_git_patch] Strategy 1 (full): Computing merge-base with main (ignoring any stale origin/agent-fix/example)
[generate_git_patch] Strategy 1 (full): origin/main exists locally
[generate_git_patch] Strategy 1 (full): Computed merge-base: <sha>
[generate_git_patch] Strategy 1: Resolved baseRef <sha> to SHA <sha>
[generate_git_patch] Strategy 1: Found 2 commits between <sha> and <sha>
[generate_git_patch] Strategy 1: Branch 'agent-fix/example' does not exist locally - ERR_SYSTEM: remote: Invalid username or token. Password authentication is not supported for Git operations.

The error handed back to the agent:

Pinned SHA <sha> failed to generate patch: ERR_SYSTEM: remote: Invalid username or token.
Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/<org>/<repo>.git/'
fatal: could not fetch <sha> from promisor remote

Reproduced twice within the same run (the agent retried), and the branch did exist locally — the commits were made in that working copy and the same trace had just enumerated them.

Why this is a bug, not configuration

  1. The branch is local. Strategy 1 has already resolved the merge-base and counted the commits on that branch in that working copy. A network call to decide whether it "exists locally" is a contradiction.
  2. No credentials are available by design. Every gh-aw-emitted actions/checkout uses persist-credentials: false. "Configure Git credentials" runs later in the job and does not cover this call site, so any git operation reaching the remote here is guaranteed to fail auth.
  3. The failure is misclassified. An ERR_SYSTEM auth error is reported as "does not exist locally", which points anyone debugging it in the wrong direction, and it aborts the strategy instead of falling back.
  4. Blobless clones compound it. With --filter=blob:none the same call additionally needs promisor hydration (could not fetch <sha> from promisor remote) — so even with credentials, patch generation is reaching for objects it should be reading locally.

Impact

Any agentic workflow using the create-pull-request safe output on v0.86.1+ can investigate, edit, validate, and commit — and then silently cannot deliver. No PR appears, and the only trace is the misleading "does not exist locally" line in the MCP gateway log.

Expected

Strategy 1 should determine branch existence from local refs only (e.g. git rev-parse --verify --quiet refs/heads/<branch>) and generate the patch from local objects, with no remote access. If a remote call is genuinely required, it must (a) use the job's credentials and (b) report an auth failure as an auth failure, then fall back rather than abort.

Environment

  • gh-aw v0.86.2 (failing) vs v0.85.4 (working); also reproduced on v0.86.1
  • engine: copilot, strict security, Linux runner
  • checkout: gh-aw defaults (persist-credentials: false, fetch-depth: 1), plus a workflow step that runs git fetch --filter=blob:none --tags --unshallow origin
  • create-pull-request safe output with preserve-branch-name: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions