-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper exit status for failed CLI requests #12375
Conversation
Some CLI commands simply `print` messages when the requests fail. The issue is the exit code for these commands are `0` while it should be non-zero. More proper exist status ensures people can better make use of the CLI.
2c3c8c9
to
90da8cb
Compare
@@ -65,7 +65,7 @@ def variables_import(args): | |||
if os.path.exists(args.file): | |||
_import_helper(args.file) | |||
else: | |||
print("Missing variables file.") | |||
raise SystemExit("Missing variables file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise SystemExit("Missing variables file.") | |
raise SystemExit("\n\tMissing variables file.") |
If we want to be consistent... but to be honest I'm not sure if we need this "prefix".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style consistency will need more effort. For example:
- with or without prefix "\n\t" are varying among different sub-command-groups (the same raises in
user_command.py
are withOUT this "prefix"). - some CLI failures are directly throwing "original" Python exceptions.
In this PR I would dedicate on the exit status, if you don't mind.
The PR should be OK to be merged with just subset of tests as it does not modify Core of Airflow. The committers might merge it or can add a label 'full tests needed' and re-run it to run all tests if they see it is needed! |
90da8cb
to
f5b1468
Compare
This PR is a followup after apache#12375 and apache#12704 it improves handling of some errors in cli commands to avoid show users to much traceback and uses SystemExit consitently.
Some CLI commands simply
print
messages when the requests fail. The issue is the exit code for these commands are0
while it should be non-zero.Pursuing very detailed status code may not make sense here. But we can at least ensure we give non-zero status by using
raise SystemExit()
.More proper exist status ensures people can better make use of the CLI.
(A few minor string expression issues are fixed here as well).
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.