Skip to content
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

Merged
merged 2 commits into from
Nov 15, 2020

Conversation

XD-DENG
Copy link
Member

@XD-DENG XD-DENG commented Nov 15, 2020

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.

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.

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.
@XD-DENG XD-DENG added priority:medium Bug that should be fixed before next release but would not block a release type:improvement Changelog: Improvements labels Nov 15, 2020
@XD-DENG XD-DENG added this to the Airflow 2.0.0-beta3 milestone Nov 15, 2020
@@ -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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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".

Copy link
Member Author

@XD-DENG XD-DENG Nov 15, 2020

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.

@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label Nov 15, 2020
@github-actions
Copy link

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!

@XD-DENG XD-DENG changed the title More proper exit status for failed CLI requests Proper exit status for failed CLI requests Nov 15, 2020
@XD-DENG XD-DENG merged commit 561e459 into apache:master Nov 15, 2020
@XD-DENG XD-DENG deleted the consistent-cli-exit-code branch November 15, 2020 20:39
turbaszek added a commit to PolideaInternal/airflow that referenced this pull request Dec 2, 2020
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.
turbaszek added a commit that referenced this pull request Dec 4, 2020
This PR is a followup after #12375 and #12704 it improves handling
of some errors in cli commands to avoid show users to much traceback
and uses SystemExit consistently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI okay to merge It's ok to merge this PR as it does not require more tests priority:medium Bug that should be fixed before next release but would not block a release type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants