Fix env var auth when config file has credentials for a different instance#181
Merged
jlaneve merged 1 commit intomainastronomer/agents:mainfrom Apr 9, 2026
fix/v3-token-exchange-env-varsastronomer/agents:fix/v3-token-exchange-env-varsCopy head branch name to clipboard
Merged
Fix env var auth when config file has credentials for a different instance#181jlaneve merged 1 commit intomainastronomer/agents:mainfrom fix/v3-token-exchange-env-varsastronomer/agents:fix/v3-token-exchange-env-varsCopy head branch name to clipboard
jlaneve merged 1 commit intomainastronomer/agents:mainfrom
fix/v3-token-exchange-env-varsastronomer/agents:fix/v3-token-exchange-env-varsCopy head branch name to clipboard
Conversation
…tance When AIRFLOW_API_URL is set via env var, don't inherit auth (token, username, password) from the config file since those credentials are for the config file's instance, not the env var's. This caused 403 errors when pointing af at a local Airflow while the config had a cloud instance token. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
schnie
approved these changes
Apr 9, 2026
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
Fixes a bug where
afCLI commands return 403 when usingAIRFLOW_API_URLto point at a local Airflow instance while~/.af/config.yamlhas credentials for a different (e.g., cloud) instance.Root cause
The env var precedence logic in
CLIContext.init()resolves each field independently:Since
auth_tokentakes precedence overusername/passwordinAdapterManager.configure(), the cloud token is used against localhost — 403.Fix
When
AIRFLOW_API_URLis set via env var (overriding the config's URL), don't inherit auth fields from the config file since they belong to a different instance. Auth from env vars still works.Testing
All 433 unit tests pass.
🤖 Generated with Claude Code