Treat empty workload identity tokens as absent - #1842
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Treat an empty
ANTHROPIC_IDENTITY_TOKENas absent instead of selecting workload identity federation with an empty assertion.The direct federation credential chain currently detects a literal identity token with an environment-membership check. That treats
ANTHROPIC_IDENTITY_TOKEN=""as a configured credential. When the federation rule and organization variables are also set, this can select the federation path ahead of fallback credentials and eventually attempt a token exchange with an empty assertion.The same gap exists after provider construction: the env-backed identity-token provider re-reads the variable on every exchange so token rotation is supported, but it only rejects a missing variable. If a previously valid variable is rotated to an empty string, the provider can again attempt an empty assertion.
Fix
Use a truthy value when deciding whether a literal identity token is available, matching the credential chain's handling of other environment variables.
The env-backed provider also rejects both missing and empty values when it re-reads the token at exchange time.
An explicitly configured
ANTHROPIC_IDENTITY_TOKEN_FILEstill takes precedence and remains usable when the literal token variable is present but empty.Regression coverage
Adds focused tests verifying that:
The change is confined to the hand-maintained credential-resolution chain.