Narrow AirflowException to specific exceptions in DataSync operator#70152
Open
haseebmalik18 wants to merge 1 commit into
Open
Narrow AirflowException to specific exceptions in DataSync operator#70152haseebmalik18 wants to merge 1 commit into
haseebmalik18 wants to merge 1 commit into
Conversation
Sanjays2402
reviewed
Jul 21, 2026
| valid = True | ||
| if not valid: | ||
| raise AirflowException( | ||
| raise ValueError( |
There was a problem hiding this comment.
switching this from AirflowException to ValueError is a behavior change for anyone catching AirflowException around operator construction, since ValueError isn't in that hierarchy. the raises in execute() all stay AirflowException subclasses, so this one's now the odd one out. intentional?
Contributor
Author
There was a problem hiding this comment.
Yeah, intentional. The constructor check is argument validation, so ValueError fits it better, while the execute failures stay AirflowException subclasses. It's also at parse time where the DAG loader catches broad Exception, so a bad config still surfaces as a normal import error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The AWS DataSync operator raised the catch-all
AirflowExceptionfor ten unrelated conditions, so a DAG author could not distinguish an invalid constructor call from a failed task execution when handling errors.This narrows each usage to a specific type:
ValueError.aws/exceptions.py:DataSyncTaskNotFoundErrorDataSyncMultipleTasksError/DataSyncMultipleLocationsErrorDataSyncLocationNotFoundErrorDataSyncTaskCreationErrorDataSyncTaskExecutionFailedErrorThe new classes subclass
AirflowException, so existingexcept AirflowExceptionhandlers keep working, with no breaking change.Tests are updated to assert the specific types, with added coverage for the raise sites that were previously untested.
Part of the ongoing effort to reduce direct
AirflowExceptionusage. Thecheck-no-new-airflow-exceptionsallowlist entry for this file is tightened from 10 to 0.