diff --git a/airflow-core/src/airflow/cli/commands/connection_command.py b/airflow-core/src/airflow/cli/commands/connection_command.py index 79bd77e53bf50..7fe430c05bfe3 100644 --- a/airflow-core/src/airflow/cli/commands/connection_command.py +++ b/airflow-core/src/airflow/cli/commands/connection_command.py @@ -66,9 +66,7 @@ def _connection_mapper(conn: Connection) -> dict[str, Any]: def connections_get(args): """Get a connection.""" try: - from airflow.sdk import BaseHook - - conn = BaseHook.get_connection(args.conn_id) + conn = Connection.get_connection_from_secrets(args.conn_id) except AirflowNotFoundException: raise SystemExit("Connection not found.") AirflowConsole().print_as( diff --git a/airflow-core/tests/unit/cli/commands/test_connection_command.py b/airflow-core/tests/unit/cli/commands/test_connection_command.py index e8b6f5d98e31d..1ebb415aa0f82 100644 --- a/airflow-core/tests/unit/cli/commands/test_connection_command.py +++ b/airflow-core/tests/unit/cli/commands/test_connection_command.py @@ -30,7 +30,7 @@ from airflow.cli import cli_config, cli_parser from airflow.cli.commands import connection_command -from airflow.exceptions import AirflowException, AirflowNotFoundException +from airflow.exceptions import AirflowException from airflow.models import Connection from airflow.utils.db import merge_conn from airflow.utils.session import create_session @@ -61,8 +61,7 @@ def test_cli_connection_get(self): stdout = stdout.getvalue() assert "google-cloud-platform:///default" in stdout - def test_cli_connection_get_invalid(self, mock_supervisor_comms): - mock_supervisor_comms.send.side_effect = AirflowNotFoundException + def test_cli_connection_get_invalid(self): with pytest.raises(SystemExit, match=re.escape("Connection not found.")): connection_command.connections_get(self.parser.parse_args(["connections", "get", "INVALID"]))