[PR #7562] fix(github): skip git config when using GITHUB_TOKEN to prevent duplicate Authorization header #12439

Closed
opened 2026-02-16 18:17:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/7562

State: closed
Merged: No


Problem

When using opencode GitHub action without the TOKEN parameter, the action configures git authentication by setting http.https://github.com/.extraheader with an AUTHORIZATION header. This conflicts with GitHub Actions' built-in authentication, causing the error:

remote: Duplicate header: "Authorization" fatal: unable to access 'https://github.com/.../': The requested URL returned error: 400

This happens when git push is executed.

Root Cause

The configureGit() function always sets git config with custom authentication header, even when the GitHub Actions runner already has proper authentication configured via GITHUB_TOKEN (provided by GitHub Actions or passed via TOKEN parameter).

Solution

Modified configureGit() and restoreGitConfig() to:

  1. Check if TOKEN environment variable is set (via useEnvGithubToken())
  2. When TOKEN is set, skip configuring http.https://github.com/.extraheader
  3. Only configure git user.name and git user.email
  4. Also skip restoreGitConfig() when using GITHUB_TOKEN

This prevents the duplicate Authorization header error because:

  • GitHub Actions runner already has proper credentials configured
  • We don't add conflicting authentication headers
  • Git operations work with the runner's existing authentication

Testing

Users experiencing the error can either:

  1. Add token: \\ to their workflow (explicitly use GITHUB_TOKEN)
  2. Update to this version of the action (automatic fix)

Related Issue

Fixes #7325

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7562 **State:** closed **Merged:** No --- ## Problem When using opencode GitHub action without the `TOKEN` parameter, the action configures git authentication by setting `http.https://github.com/.extraheader` with an `AUTHORIZATION` header. This conflicts with GitHub Actions' built-in authentication, causing the error: `` remote: Duplicate header: "Authorization" fatal: unable to access 'https://github.com/.../': The requested URL returned error: 400 `` This happens when `git push` is executed. ## Root Cause The `configureGit()` function always sets git config with custom authentication header, even when the GitHub Actions runner already has proper authentication configured via GITHUB_TOKEN (provided by GitHub Actions or passed via `TOKEN` parameter). ## Solution Modified `configureGit()` and `restoreGitConfig()` to: 1. Check if `TOKEN` environment variable is set (via `useEnvGithubToken()`) 2. When `TOKEN` is set, skip configuring `http.https://github.com/.extraheader` 3. Only configure git user.name and git user.email 4. Also skip `restoreGitConfig()` when using GITHUB_TOKEN This prevents the duplicate Authorization header error because: - GitHub Actions runner already has proper credentials configured - We don't add conflicting authentication headers - Git operations work with the runner's existing authentication ## Testing Users experiencing the error can either: 1. Add `token: \\` to their workflow (explicitly use GITHUB_TOKEN) 2. Update to this version of the action (automatic fix) ## Related Issue Fixes #7325
yindo added the pull-request label 2026-02-16 18:17:21 -05:00
yindo closed this issue 2026-02-16 18:17:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12439