Skip to content

Commit ac42f12

Browse files
lpcoxCopilot
andcommitted
fix: update api-proxy health check to allow OpenAI/Codex placeholder keys
The health check was blocking startup when OPENAI_API_KEY or CODEX_API_KEY contained the placeholder value 'sk-placeholder-for-api-proxy', treating it as a credential isolation failure. Update the check to allow the known placeholder value while still rejecting any real (non-placeholder) keys. This mirrors the Anthropic pattern where ANTHROPIC_AUTH_TOKEN is allowed to hold its placeholder value. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 35e9cd1 commit ac42f12

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

containers/agent/api-proxy-health-check.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,36 @@ if [ -n "$OPENAI_BASE_URL" ]; then
6363
API_PROXY_CONFIGURED=true
6464
echo "[health-check] Checking OpenAI API proxy configuration..."
6565

66-
# Verify credentials are NOT in agent environment
67-
if [ -n "$OPENAI_API_KEY" ] || [ -n "$CODEX_API_KEY" ] || [ -n "$OPENAI_KEY" ]; then
66+
# Verify credentials are NOT in agent environment (real keys must stay in api-proxy sidecar).
67+
# A placeholder value is intentionally injected so clients like Codex v0.121+ (which bypass
68+
# OPENAI_BASE_URL when no key is present) still route through the sidecar. The placeholder
69+
# is never sent upstream — the api-proxy replaces it with the real key before forwarding.
70+
AWF_PLACEHOLDER="sk-placeholder-for-api-proxy"
71+
REAL_KEY_PRESENT=false
72+
if [ -n "$OPENAI_API_KEY" ] && [ "$OPENAI_API_KEY" != "$AWF_PLACEHOLDER" ]; then
73+
REAL_KEY_PRESENT=true
74+
fi
75+
if [ -n "$CODEX_API_KEY" ] && [ "$CODEX_API_KEY" != "$AWF_PLACEHOLDER" ]; then
76+
REAL_KEY_PRESENT=true
77+
fi
78+
if [ -n "$OPENAI_KEY" ] && [ "$OPENAI_KEY" != "$AWF_PLACEHOLDER" ]; then
79+
REAL_KEY_PRESENT=true
80+
fi
81+
82+
if [ "$REAL_KEY_PRESENT" = "true" ]; then
6883
echo "[health-check][ERROR] OpenAI/Codex API key found in agent environment!"
6984
echo "[health-check][ERROR] Credential isolation failed - keys should only be in api-proxy container"
7085
echo "[health-check][ERROR] OPENAI_API_KEY=${OPENAI_API_KEY:+<present>}"
7186
echo "[health-check][ERROR] CODEX_API_KEY=${CODEX_API_KEY:+<present>}"
7287
echo "[health-check][ERROR] OPENAI_KEY=${OPENAI_KEY:+<present>}"
7388
exit 1
7489
fi
75-
echo "[health-check] ✓ OpenAI/Codex credentials NOT in agent environment (correct)"
90+
91+
if [ -n "$OPENAI_API_KEY" ] || [ -n "$CODEX_API_KEY" ]; then
92+
echo "[health-check] ✓ OpenAI/Codex placeholder key in agent environment (credential isolation active)"
93+
else
94+
echo "[health-check] ✓ OpenAI/Codex credentials NOT in agent environment (correct)"
95+
fi
7696

7797
# Perform health check using BASE_URL
7898
echo "[health-check] Testing connectivity to OpenAI API proxy at $OPENAI_BASE_URL..."

0 commit comments

Comments
 (0)