Skip to content

fix(auth): strip Bedrock/Vertex env vars when profile has SSO credentials#14

Merged
diranged merged 2 commits intomainfrom
fix/strip-bedrock-vertex-env-on-sso
Apr 6, 2026
Merged

fix(auth): strip Bedrock/Vertex env vars when profile has SSO credentials#14
diranged merged 2 commits intomainfrom
fix/strip-bedrock-vertex-env-on-sso

Conversation

@diranged
Copy link
Copy Markdown
Owner

@diranged diranged commented Apr 6, 2026

Summary

  • When CLAUDE_CODE_USE_BEDROCK or CLAUDE_CODE_USE_VERTEX are set in the user's shell environment (e.g. from dotfiles), they leak through to Claude Code even for profiles authenticated via SSO/keychain, causing Bedrock routing instead of the Anthropic API
  • Strip these provider flags from the environment when the profile has keychain or file-based SSO credentials
  • Model override vars (ANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL) are intentionally left alone

Test plan

  • go test ./internal/claude/... passes (4 new UnsetEnv tests)
  • go vet ./... clean
  • Manual: CLAUDE_CODE_USE_BEDROCK=1 claude-profile -P work with keychain auth shows standard model ID, not Bedrock format

🤖 Generated with Claude Code

diranged and others added 2 commits April 6, 2026 10:35
…ials

When CLAUDE_CODE_USE_BEDROCK or CLAUDE_CODE_USE_VERTEX are set in the
user's shell environment (e.g. from dotfiles), they leak through to
Claude Code even for profiles authenticated via SSO/keychain. This
causes Claude Code to use Bedrock routing instead of the Anthropic API.

Strip these provider flags from the environment when the profile has
keychain or file-based SSO credentials, since the user's intent is
clearly to use the Anthropic API for that profile.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Version variable was initialized via buildVersion(), which ran at
program startup and overwrote the value injected by goreleaser's
-X ldflags. Move the fallback into an init() that only runs when
ldflags did not set Version.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@diranged diranged marked this pull request as ready for review April 6, 2026 17:38
@diranged diranged merged commit 8bda8e1 into main Apr 6, 2026
2 checks passed
@diranged diranged deleted the fix/strip-bedrock-vertex-env-on-sso branch April 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant