This is an automated email from the ASF dual-hosted git repository.

turaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new ffa2fb21e01 Fix airflowctl version command prompting for keyring 
credentials (#63772)
ffa2fb21e01 is described below

commit ffa2fb21e01908fe242aa39d6c967982bcc91d58
Author: Dheeraj Turaga <[email protected]>
AuthorDate: Tue Mar 17 15:31:17 2026 -0500

    Fix airflowctl version command prompting for keyring credentials (#63772)
---
 .../src/airflowctl/ctl/commands/version_command.py       | 14 ++++++--------
 .../airflow_ctl/ctl/commands/test_version_command.py     | 16 +++++++---------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/airflow-ctl/src/airflowctl/ctl/commands/version_command.py 
b/airflow-ctl/src/airflowctl/ctl/commands/version_command.py
index bfaa49a6682..d1f9034e033 100644
--- a/airflow-ctl/src/airflowctl/ctl/commands/version_command.py
+++ b/airflow-ctl/src/airflowctl/ctl/commands/version_command.py
@@ -19,16 +19,14 @@ from __future__ import annotations
 import rich
 
 from airflowctl import __version__ as airflowctl_version
-from airflowctl.api.client import NEW_API_CLIENT, ClientKind, 
provide_api_client
+from airflowctl.api.client import ClientKind, get_client
 
 
-@provide_api_client(kind=ClientKind.CLI)
-def version_info(arg, api_client=NEW_API_CLIENT):
+def version_info(arg):
     """Get version information."""
     version_dict = {"airflowctl_version": airflowctl_version}
     if arg.remote:
-        version_response = api_client.version.get()
-        version_dict.update(version_response.model_dump())
-        rich.print(version_dict)
-    else:
-        rich.print(version_dict)
+        with get_client(kind=ClientKind.CLI, api_token=getattr(arg, 
"api_token", None)) as api_client:
+            version_response = api_client.version.get()
+            version_dict.update(version_response.model_dump())
+    rich.print(version_dict)
diff --git a/airflow-ctl/tests/airflow_ctl/ctl/commands/test_version_command.py 
b/airflow-ctl/tests/airflow_ctl/ctl/commands/test_version_command.py
index 72998b97442..e6b20ed7fa5 100644
--- a/airflow-ctl/tests/airflow_ctl/ctl/commands/test_version_command.py
+++ b/airflow-ctl/tests/airflow_ctl/ctl/commands/test_version_command.py
@@ -30,16 +30,12 @@ from airflowctl.ctl.commands.version_command import 
version_info
 @pytest.fixture
 def mock_client():
     """create a mock client"""
-    with mock.patch("airflowctl.api.client.get_client") as mock_get_client:
-        client = mock.MagicMock(spec=Client)
-        mock_get_client.return_value.__enter__.return_value = client
-
+    client = mock.MagicMock(spec=Client)
     client.version.get.return_value.model_dump.return_value = {
         "version": "3.1.0",
         "git_version": None,
         "airflowctl_version": "0.1.0",
     }
-
     return client
 
 
@@ -49,15 +45,17 @@ class TestVersionCommand:
     parser = cli_parser.get_parser()
 
     def test_ctl_version_remote(self, mock_client):
-        with redirect_stdout(StringIO()) as stdout:
-            version_info(self.parser.parse_args(["version", "--remote"]), 
api_client=mock_client)
+        with mock.patch("airflowctl.ctl.commands.version_command.get_client") 
as mock_get_client:
+            mock_get_client.return_value.__enter__.return_value = mock_client
+            with redirect_stdout(StringIO()) as stdout:
+                version_info(self.parser.parse_args(["version", "--remote"]))
             assert "version" in stdout.getvalue()
             assert "git_version" in stdout.getvalue()
             assert "airflowctl_version" in stdout.getvalue()
 
     def test_ctl_version_only_local_version(self, mock_client):
-        """Test the version command with an exception."""
+        """Test the version command without --remote does not touch 
credentials."""
         with redirect_stdout(StringIO()) as stdout:
-            version_info(self.parser.parse_args(["version"]), 
api_client=mock_client)
+            version_info(self.parser.parse_args(["version"]))
             output = stdout.getvalue()
         assert "airflowctl_version" in output

Reply via email to