This is an automated email from the ASF dual-hosted git repository.
vatsrahul1001 pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 436f4797b77 [v3-3-test] Fix airflow connections test returning success
exit code on failure (#72548) (#72583)
436f4797b77 is described below
commit 436f4797b7730dbd72a91d4e135b3c705c2a07bc
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Sep 7 11:05:41 2026 +0530
[v3-3-test] Fix airflow connections test returning success exit code on
failure (#72548) (#72583)
The failure branch in connections_test only printed the error message
without raising SystemExit(1), unlike the other two failure paths in
the same function. Any script that checks the exit code of this
command would treat a failed connection test as a success.
(cherry picked from commit 20563781c3d9c059985e1f9b741f9414e21bd8f8)
Co-authored-by: Jyun-An Chen <[email protected]>
---
airflow-core/src/airflow/cli/commands/connection_command.py | 1 +
airflow-core/tests/unit/cli/commands/test_connection_command.py | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/airflow-core/src/airflow/cli/commands/connection_command.py
b/airflow-core/src/airflow/cli/commands/connection_command.py
index ce87af7a9c3..ee0a8089c7c 100644
--- a/airflow-core/src/airflow/cli/commands/connection_command.py
+++ b/airflow-core/src/airflow/cli/commands/connection_command.py
@@ -471,3 +471,4 @@ def connections_test(args) -> None:
console.print("[bold green]\nConnection success!\n")
else:
console.print(f"[bold][red]\nConnection failed![/bold]\n{message}\n")
+ raise SystemExit(1)
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 c62dfb4c5b3..c75f1eeb642 100644
--- a/airflow-core/tests/unit/cli/commands/test_connection_command.py
+++ b/airflow-core/tests/unit/cli/commands/test_connection_command.py
@@ -1073,9 +1073,10 @@ class TestCliTestConnections:
mock_test_conn =
mocker.patch("airflow.providers.http.hooks.http.HttpHook.test_connection")
conn_id = "http_default"
mock_test_conn.return_value = False, "Failed."
- with stdout_capture as stdout:
+ with stdout_capture as stdout, pytest.raises(SystemExit) as exc_info:
connection_command.connections_test(self.parser.parse_args(["connections",
"test", conn_id]))
- assert "Connection failed!\nFailed.\n\n" in stdout.getvalue()
+ assert exc_info.value.code == 1
+ assert "Connection failed!\nFailed.\n\n" in stdout.getvalue()
def test_cli_connections_test_missing_conn(self, mocker, stdout_capture):
mocker.patch.dict(os.environ, {"AIRFLOW__CORE__TEST_CONNECTION":
"Enabled"})