Repository navigation
Shortcircuit command call on error - #49438
Conversation
|
@bugraoz93 what are your thoughts? I felt this was the most minimal way of shorting the command call. If the credential check fails it exits early with the error |
@aritra24 I first did this too, but printing an error to the user on api package is undesirable.
def safe_call_action_command(function: Callable, args:Iterable[Arg]) -> None:
try:
function(args)
except AirflowCtlNotFoundException as e:
rich.print(f"Error: {e}")
from airflowctl.ctl.cli_parser import safe_call_action_command
def main():
parser = cli_parser.get_parser()
argcomplete.autocomplete(parser)
args = parser.parse_args()
safe_call_action_command(args.func, args=args)airflow/airflow-ctl/src/airflowctl/__main__.py Lines 29 to 33 in 113528c |
bugraoz93
left a comment
There was a problem hiding this comment.
The next step should be throw specific exception class indicating only credentials not fiund and gove specific error message from ctl package. Thanks for the changes!
|
@bugraoz93 do we wanna do it as part of this pr? Or as a follow up? |
If you can do it in this that would be great! Because then we can use more granular exceptions. Let me put request change to prevent merge |
bugraoz93
left a comment
There was a problem hiding this comment.
Just put to make granular exception and giving message in safe call
|
Ack, sounds good! Will do |
|
@bugraoz93 is this kind of what you were talking about wrt your last comment? Adding a more granular sub exception? |
bugraoz93
left a comment
There was a problem hiding this comment.
Thanks for the changes and for addressing the comment! We should drive AirflowCtlFileNotFoundException while working with files in commands such as connections, variables or pools. Then we can easily identify them and map proper errors.
|
@bugraoz93 / @potiuk if this is ready we can merge this in? |
* Moved error check up to ctl level * More granular exceptions
closes: #49139
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an 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 a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.