liwenjie200543 opened a new pull request, #73808: URL: https://github.com/apache/airflow/pull/73808
`provide_api_client` forwarded only `api_token` from the parsed args namespace, so every `@provide_api_client`-decorated command resolved credentials against the production environment no matter what `--env` the user passed. `version --remote`, which calls `get_client` directly, ignored `--env` the same way even though the flag is attached to the command (cli_config.py:1313). Net effect: `airflowctl dags list --env staging` silently used production credentials — the failure mode described in the issue. closes: #70519 **What changed** - `get_client()` gains `api_environment` and forwards it to `Credentials`, whose own contract (`AIRFLOW_CLI_ENVIRONMENT` beats the explicit value) is preserved. - The `provide_api_client` wrapper reads `env` off the parsed args namespace, falling back to `"production"` — the same default `ARG_AUTH_ENVIRONMENT` and `Credentials` use, so callers that never pass `--env` are unaffected. - `version_command.version_info` forwards `--env` for its direct `get_client` call. This supersedes #70584, which was closed unmerged under the 5-open-PR limit rather than for its approach; the decorator and `version --remote` paths are now both covered by tests. **Tests** - `TestGetClientEnvironment` (`airflow-ctl/tests/airflow_ctl/api/test_client.py`): default stays production; explicit `api_environment="staging"` resolves `staging.json`; same for `NO_AUTH`; `AIRFLOW_CLI_ENVIRONMENT` keeps precedence; the decorator forwards `env` from the args namespace. - `test_version_command.py`: the two mocked-call assertions updated for the new kwarg, plus a new `test_ctl_version_remote_with_env` covering `--env staging`. - Red/green: the four environment tests fail on `main` and pass on this branch (verified by stashing the source fix while keeping the tests). --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: [ZCode (GLM-5.3-Flash)] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
