Skip to content

fix(cli): allow remote version check without local config file#65099

Open
rjgoyln wants to merge 3 commits intoapache:mainfrom
rjgoyln:fix/remote-version-token-only-support
Open

fix(cli): allow remote version check without local config file#65099
rjgoyln wants to merge 3 commits intoapache:mainfrom
rjgoyln:fix/remote-version-token-only-support

Conversation

@rjgoyln
Copy link
Copy Markdown
Contributor

@rjgoyln rjgoyln commented Apr 12, 2026

Summary

This PR fixes a bug where version --remote (and other CLI commands) fails if a local configuration file is missing, even when a valid token is provided. By relaxing the strict dependency on the physical config file, the CLI now supports token-only authentication in stateless environments.

Changes

  • Credential Loading Logic: Updated the load() method in client.py to check for an existing api_token when a FileNotFoundError occurs.
  • Error Handling: Prevent AirflowCtlCredentialNotFoundException from being raised if a token is already present, allowing the client to initialize using the provided credentials.
  • Improved Flexibility: Enabled support for environments (such as CI/CD or containerized tasks) where authentication is handled via environment variables/tokens rather than a local credentials file.

Was generative AI tooling used to co-author this PR?
  • [X ] Yes (please specify the tool below)
    GPT 5.3 codex

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A command to how we should handle this case what we have already in there, enabling future cases and creating this as separate flow rather changing conditions.
To be honest any condition there break things and api token shouldn't be none any case, the behaviour should skip entire flow there as in ClientKind.NO_AUTH.

if self.client_kind != ClientKind.AUTH:
# This is expected during the auth login command.
# Also allow token-only usage without local config (for commands like `version --remote`).
if self.client_kind != ClientKind.AUTH and self.api_token is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be None in some cases.
How about we do something like this and eliminate auth kind for version fully as well as --remote which version should already respond without auth
Here I have added NO_AUTH
https://github.com/apache/airflow/pull/61822/changes#diff-6c1e70e5894d838261bf4f502f2f117eed5e35dfcaa211f4e2b1070d632fda02R94

Then setting correct path and cascade to credentials in the same file. That would also enable similar cases in the future. You can find all corrolated changes there. There are some more with schema management but you can ignore all. In version command when call with not auth we can skip auth for all rather changing the behavior when we actually auth.
That could break things. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, @bugraoz93! I agree that adding ClientKind.NO_AUTH is a cleaner and more robust approach than extra conditional checks.
I’ve made the changes—let me know if anything needs adjustment.
Also, I couldn’t find your NO_AUTHimplementation in #61882, sorry!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so strange is the ids are duplicates 😕
#61822. This PR is showing me different my PR while when I click your link it shows Jareks 🤔

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Linux, it saved webm, if it won't be visible here is mp4 :D The PR is called Decouple airflowctl tests from branch dependency and add schema evolution with strict versioning

Screencast.from.2026-04-13.19-39-50.mp4

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants