Skip to content

fix(shared/token-manager): classify env-fallback keyType by capability - #1490

Open
PratikDhanave (PratikDhanave) wants to merge 1 commit into
microsoft:mainfrom
PratikDhanave:fix/token-manager-env-keytype
Open

PratikDhanave (PratikDhanave) wants to merge 1 commit into
microsoft:mainfrom
PratikDhanave:fix/token-manager-env-keytype

Conversation

@PratikDhanave

Copy link
Copy Markdown

Summary

acquireTokenFull's env-fallback branch (packages/shared/src/token-manager/client.ts) set:

keyType: capability === "claude-code-cli" ? "anthropic-api-key" : "github-oauth",

But KEY_CAPABILITY_ENV_VARS maps "anthropic-api" → ANTHROPIC_API_KEY and "azure-ai-inference" → AZURE_AI_INFERENCE_API_KEY. So acquireTokenFull("anthropic-api") with ANTHROPIC_API_KEY set returns keyType: "github-oauth" for an Anthropic key — while acquireTokenFull("claude-code-cli") with the same env var returns "anthropic-api-key". The method's JSDoc says callers use keyType "to set the correct env var", and capabilities.ts documents anthropic-api → anthropic-api-key, azure-ai-inference → azure-ai-foundry.

Change

Classify the env-fallback keyType: claude-code-cli/anthropic-api → anthropic-api-key; azure-ai-inference → azure-ai-foundry; else github-oauth.

Verification

Regression test — acquireTokenFull("anthropic-api") with ANTHROPIC_API_KEY set. Fails before (github-oauth), passes after (anthropic-api-key). vitest client suite → 14 passed.

(Note: only claude-code-cli has a live caller today, so this is a latent self-contradiction, but a real one.)

acquireTokenFull's env-fallback branch set
keyType = capability === "claude-code-cli" ? "anthropic-api-key" : "github-oauth".
But KEY_CAPABILITY_ENV_VARS maps "anthropic-api" -> ANTHROPIC_API_KEY and
"azure-ai-inference" -> AZURE_AI_INFERENCE_API_KEY, so acquireTokenFull("anthropic-api")
with ANTHROPIC_API_KEY set returned keyType "github-oauth" for an Anthropic key —
while "claude-code-cli" with the same env var returns "anthropic-api-key".
Callers rely on keyType "to set the correct env var" (per the method's JSDoc),
and the capabilities table maps anthropic-api -> anthropic-api-key and
azure-ai-inference -> azure-ai-foundry. Classify accordingly.

Add a regression test for the anthropic-api env fallback.
@cedricvidal Cedric Vidal (cedricvidal) added the community-contribution Pull requests submitted by external community contributors. label Oct 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Pull requests submitted by external community contributors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants