Repository navigation
Description
Bug Report
Description
When using BYOK (Bring Your Own Key) with COPILOT_PROVIDER_API_KEY and COPILOT_PROVIDER_BASE_URL pointing to an external provider (e.g. OpenRouter), every request to the api-proxy fails with:
400 400 bad request: Authorization header is badly formatted
This happens on every attempt (all 4 retries exhaust), causing the entire agent run to fail.
Environment
- gh-aw version: v0.71.4
- Runner image: ubuntu-24.04 (20260413.86.1)
- Model:
minimax/minimax-m2.5:free(via OpenRouter) - COPILOT_PROVIDER_BASE_URL:
https://openrouter.ai/api/v1
Steps to Reproduce
- Set
COPILOT_PROVIDER_BASE_URLandCOPILOT_PROVIDER_API_KEYin the workflow .md config file for BYOK mode. - Trigger the agentic workflow.
- Observe the agent container logs.
Observed Behavior
The health check passes and correctly identifies offline+BYOK mode:
[health-check] ✓ COPILOT_PROVIDER_API_KEY is placeholder value (correct)
[health-check] COPILOT_PROVIDER_BASE_URL=http://172.30.0.30:10002 (offline+BYOK mode)
[health-check] ✓ Copilot CLI offline+BYOK mode configured
[health-check] ✓ All API proxy health checks passed
But all inference requests immediately fail:
● Request failed (transient_bad_request). Retrying...
● Request failed (transient_bad_request). Retrying...
400 400 bad request: Authorization header is badly formatted
Additionally, the models endpoint also returns 400:
[copilot-harness] awf-reflect: models fetch returned 400 for http://api-proxy:10002/models
The harness does not classify this as an auth error (isAuthError=false), so all 3 retries are consumed before giving up:
[copilot-harness] attempt 4 failed: exitCode=1 isCAPIError400=false isMCPPolicyError=false isModelNotSupportedError=false isNullTypeToolCallError=false isAuthError=false hasOutput=true retriesRemaining=0
[copilot-harness] all 3 retries exhausted — giving up (exitCode=1)
Expected Behavior
The api-proxy sidecar should correctly inject the COPILOT_PROVIDER_API_KEY as a properly formatted Authorization: Bearer <key> header when proxying requests to the external provider URL.
Additionally, a badly-formatted Authorization header (400 from the upstream provider) should ideally be classified as a non-retryable auth error to fail fast rather than exhausting all retries.
Additional Context
- The
COPILOT_API_KEYenv var inside the container is correctly set to thedummy-byok-key-for-offline-modeplaceholder. - The actual provider key (
COPILOT_PROVIDER_API_KEY) is held securely in the sidecar proxy container. - The issue appears to be in how the sidecar proxy formats the Authorization header when forwarding requests upstream to the external provider.
Activity
MauroDruwel commentedon May 4, 2026
Additional context:
The env variables are configured exactly as documented/recommended in a prior issue. The
.mdworkflow file has:All three variables (
vars.PROVIDER_BASE_URL,vars.PROVIDER_MODEL,secrets.PROVIDER_API_KEY) are set in the repository settings. The configuration matches what was advised in a prior issue, yet BYOK still fails with theAuthorization header is badly formattederror in v0.71.4.lpcox commentedon May 4, 2026
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#2513
MauroDruwel commentedon May 5, 2026
I'm still having the same issue after upgrading to this new version. How can I debug this further?
lpcox commentedon May 5, 2026
@MauroDruwel can you confirm you're using v0.71.5?
lpcox commentedon May 7, 2026
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#2665
MauroDruwel commentedon May 7, 2026
I am, you can look at this workflow run https://github.com/MauroDruwel/Copilot-Spawner/actions/runs/25494923769/job/74812149926, maybe I'm doing something wrong but I can't seem to find it 😅
lpcox commentedon May 7, 2026
@MauroDruwel looking into it!
lpcox commentedon May 7, 2026
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#2703
lpcox commentedon May 9, 2026
🔗 AWF tracking issue: https://github.com/github/gh-aw-firewall/issues/github/gh-aw-firewall#2806
lpcox commentedon May 9, 2026
Resolved in gh-aw-firewall by commit 899ee4b (
stripBearerPrefix()fix). See github/gh-aw-firewall#2806