Skip to content

Commit 09cb7e1

Browse files
authored
fix(api-proxy): exclude GEMINI_API_BASE_URL from env-all passthrough
Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/45da4d20-2dd1-4626-bdd7-cfe45a6c0037
1 parent 40c7bd9 commit 09cb7e1

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

docs/api-proxy-sidecar.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ Fields:
432432

433433
### Gemini proxy returns 503
434434

435-
When `--enable-api-proxy` is active, `GOOGLE_GEMINI_BASE_URL`, `GEMINI_API_BASE_URL`, and a placeholder `GEMINI_API_KEY` are always injected into the agent container. If the real `GEMINI_API_KEY` was not set in the AWF runner environment, the api-proxy Gemini listener (port 10003) responds with **503** to all requests.
435+
When `--enable-api-proxy` is active **and `GEMINI_API_KEY` is provided to the AWF runner**, `GOOGLE_GEMINI_BASE_URL`, `GEMINI_API_BASE_URL`, and a placeholder `GEMINI_API_KEY` are injected into the agent container. If the real `GEMINI_API_KEY` was not set in the AWF runner environment, the Gemini routing vars are never set and the api-proxy Gemini listener (port 10003) responds with **503** to any requests that do reach it.
436436

437437
**Solution**: Export `GEMINI_API_KEY` in the runner environment before invoking AWF. In GitHub Actions, add it to the step's `env:` block and use `sudo --preserve-env`:
438438

src/docker-manager.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,6 +3094,24 @@ describe('docker-manager', () => {
30943094
}
30953095
});
30963096

3097+
it('should not inherit GEMINI_API_BASE_URL from host env via envAll when geminiApiKey is absent', () => {
3098+
const origVal = process.env.GEMINI_API_BASE_URL;
3099+
process.env.GEMINI_API_BASE_URL = 'http://some-other-proxy';
3100+
try {
3101+
const configWithProxy = { ...mockConfig, enableApiProxy: true, openaiApiKey: 'sk-test-key', envAll: true };
3102+
const result = generateDockerCompose(configWithProxy, mockNetworkConfigWithProxy);
3103+
const env = result.services.agent.environment as Record<string, string>;
3104+
// GEMINI_API_BASE_URL is in EXCLUDED_ENV_VARS so it must not be inherited from host
3105+
expect(env.GEMINI_API_BASE_URL).toBeUndefined();
3106+
} finally {
3107+
if (origVal !== undefined) {
3108+
process.env.GEMINI_API_BASE_URL = origVal;
3109+
} else {
3110+
delete process.env.GEMINI_API_BASE_URL;
3111+
}
3112+
}
3113+
});
3114+
30973115
it('should NOT set GEMINI_API_KEY placeholder in agent when api-proxy is enabled without geminiApiKey', () => {
30983116
const configWithProxy = { ...mockConfig, enableApiProxy: true, openaiApiKey: 'sk-test-key' };
30993117
const result = generateDockerCompose(configWithProxy, mockNetworkConfigWithProxy);

src/docker-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ export function generateDockerCompose(
773773
EXCLUDED_ENV_VARS.add('CLAUDE_API_KEY');
774774
EXCLUDED_ENV_VARS.add('GEMINI_API_KEY');
775775
EXCLUDED_ENV_VARS.add('GOOGLE_GEMINI_BASE_URL');
776+
EXCLUDED_ENV_VARS.add('GEMINI_API_BASE_URL');
776777
// COPILOT_GITHUB_TOKEN and COPILOT_API_KEY get placeholders (not excluded), protected by one-shot-token
777778
// GITHUB_API_URL is intentionally NOT excluded: the Copilot CLI needs it to know the
778779
// GitHub API base URL. Copilot-specific API calls (inference and token exchange) go

0 commit comments

Comments
 (0)