Repository navigation
Fix airflow connections test returning success exit code on failure - #72548
Conversation
Shriprasad-P
left a comment
There was a problem hiding this comment.
Reviewed the failure and success paths for connections_test().
On main, the disabled-test and missing-connection branches already exit with status 1, while the (False, message) branch only printed Connection failed! and returned, which propagated as shell exit code 0.
Adding raise SystemExit(1) after the existing failure message is consistent with the surrounding Airflow CLI behavior and preserves the current output without introducing duplicate stderr text.
The updated test now verifies both the existing failure message and exit code 1, while the success path remains unchanged. The bugfix newsfragment also correctly documents the scripting-visible behavior change.
LGTM.
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.
ca860e6 to
4393d0d
Compare
henry3260
left a comment
There was a problem hiding this comment.
Thanks for your contribution
|
Hi maintainer, this PR was merged without a milestone set.
|
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…on failure (apache#72548) 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 2056378) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
…on failure (apache#72548) 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 2056378) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
…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 2056378) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
…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 2056378) Co-authored-by: Jyun-An Chen <jun930436@gmail.com>
…pache#72548) 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.
…pache#72548) 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.
Sumarry
airflow connections test <conn_id>prints "Connection failed!" but always returns exit code 0, because the failure branch inconnections_test(airflow-core/src/airflow/cli/commands/connection_command.py) only printsthe error message without raising
SystemExit(1). The other two failure paths in the same function (test-connection disabled, connection not found) alreadyraise SystemExit(1), so this was an inconsistency rather than intentional behavior.Any script that runs this command and checks
$?(e.g. a deployment pre-flight check or a custom health check a deployment team wrote around this CLI) will treat a failed connection test as a success.Change
This PR adds
raise SystemExit(1)to the failure branch and updatestest_cli_connections_test_failto assert the exit code.