Skip to content

[awf] API Proxy: Gemini engine fails when GEMINI_API_KEY is a secret but not in runner environment #1931

@lpcox

Description

@lpcox

Problem

When using engine: gemini in a workflow, the Gemini CLI fails with exit code 41 (no authentication configured) even though GEMINI_API_KEY is correctly set as a repository secret. The failure log shows:

[INFO] API proxy enabled: OpenAI=false, Anthropic=false, Copilot=false
[WARN] ⚠️  API proxy enabled but no API keys found in environment

The GEMINI_API_BASE_URL is being set to `(host.docker.internal/redacted) (the AWF api-proxy), but the proxy reports no Gemini support.

Context

Root Cause

In src/docker-manager.ts lines 1657–1673, GEMINI_API_BASE_URL is only set to the api-proxy address when config.geminiApiKey is present. However, in the reported scenario, the api-proxy is enabled (--enable-api-proxy) but GEMINI_API_KEY is not being forwarded to the AWF process — it's being held as a repository secret injected into the GitHub Actions environment, not the AWF runner environment.

The [WARN] API proxy enabled but no API keys found means config.geminiApiKey is undefined at compose generation time (line 1672). Despite this, when the agent receives GEMINI_API_KEY through --env-all or explicit env forwarding, it gets excluded from the agent environment at line 600 (EXCLUDED_ENV_VARS.add('GEMINI_API_KEY')) when api-proxy is enabled — leaving the Gemini CLI with no credential.

Proposed Solution

  1. src/docker-manager.ts: When --enable-api-proxy is active and GEMINI_API_KEY is excluded from the agent environment (line 600), always set GEMINI_API_BASE_URL to the api-proxy address for port 10003 — regardless of whether the key is detected at compose-generation time. The api-proxy will return 503 if no key is available, which is a clearer failure than a silent auth error.

  2. src/docker-manager.ts: Change the log at line 1672 from [WARN] to [ERROR] when GEMINI_API_KEY is excluded but no key is configured — this surfaces the misconfiguration at startup rather than silently failing.

  3. containers/api-proxy/server.js: Verify the Gemini listener on port 10003 is initialized and that the health check reflects Gemini availability. Update the [INFO] API proxy enabled: ... log line to include Gemini=true/false.

  4. Docs: Update the api-proxy documentation to clarify that GEMINI_API_KEY must be present in the runner environment (not just repository secrets) when --enable-api-proxy is used, or add a mechanism to read it from the Actions secret at runtime.

Generated by Firewall Issue Dispatcher · ● 1.6M ·

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions