fix: skip Anthropic credential check in CI for 3P providers

In CI mode, auth.ts throws if ANTHROPIC_API_KEY or
CLAUDE_CODE_OAUTH_TOKEN are missing — even when using
CLAUDE_CODE_USE_OPENAI=1 or CLAUDE_CODE_USE_GEMINI=1.
This crashes any OpenAI/Gemini/Ollama CI pipeline immediately.

Fix: guard the throw with !isUsing3PServices() so non-Anthropic
providers skip the check entirely.

Also added CLAUDE_CODE_USE_GEMINI to isUsing3PServices() which
was missing — Gemini users were excluded from the 3P detection
used elsewhere in the same function.

Fixes #40.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gnanam1990
2026-04-01 20:00:42 +05:30
parent 00744a814b
commit 1278967223

View File

@@ -274,6 +274,7 @@ export function getAnthropicApiKeyWithSource(
} }
if ( if (
!isUsing3PServices() &&
!apiKeyEnv && !apiKeyEnv &&
!process.env.CLAUDE_CODE_OAUTH_TOKEN && !process.env.CLAUDE_CODE_OAUTH_TOKEN &&
!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR !process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR
@@ -1729,13 +1730,14 @@ export function getSubscriptionName(): string {
} }
} }
/** Check if using third-party services (Bedrock or Vertex or Foundry or OpenAI-compatible) */ /** Check if using third-party services (Bedrock or Vertex or Foundry or OpenAI-compatible or Gemini) */
export function isUsing3PServices(): boolean { export function isUsing3PServices(): boolean {
return !!( return !!(
isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) || isEnvTruthy(process.env.CLAUDE_CODE_USE_BEDROCK) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) || isEnvTruthy(process.env.CLAUDE_CODE_USE_VERTEX) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) || isEnvTruthy(process.env.CLAUDE_CODE_USE_FOUNDRY) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI) isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI) ||
isEnvTruthy(process.env.CLAUDE_CODE_USE_GEMINI)
) )
} }