Remove redundant try/except blocks in Bigtable operators (fix #60687)#61510
Closed
RamiNoodle733 wants to merge 1 commit intoapache:mainfrom
Closed
Remove redundant try/except blocks in Bigtable operators (fix #60687)#61510RamiNoodle733 wants to merge 1 commit intoapache:mainfrom
RamiNoodle733 wants to merge 1 commit intoapache:mainfrom
Conversation
This change removes unnecessary exception handling in Bigtable operators
where try/except blocks were catching GoogleAPICallError, logging a generic
error message, and then immediately re-raising the exception. This pattern
is redundant because:
1. The Hook methods already let exceptions bubble up naturally
2. The generic error logging ('An error occurred. Exiting.') adds no value
3. It creates unnecessary code nesting and duplication
Changes made:
- BigtableCreateInstanceOperator: Removed try/except GoogleAPICallError
- BigtableUpdateInstanceOperator: Removed try/except GoogleAPICallError
- BigtableDeleteTableOperator: Removed redundant GoogleAPICallError handler
(kept NotFound handler for idempotent delete behavior)
- BigtableUpdateClusterOperator: Removed redundant GoogleAPICallError handler
(kept NotFound handler for custom error message)
Fixes: #60687
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
Contributor
|
Please refer to guidelines regarding AI usage:
Moreover, you created a for an already-assigned issue and created PR which duplicates an existing one (#61124). |
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.
Pull Request: Remove redundant try/except blocks in Bigtable operators
Related Issue
Fixes #60687
Description
This PR removes unnecessary exception handling in Bigtable operators where try/except blocks were catching
GoogleAPICallError, logging a generic error message, and then immediately re-raising the exception.Why this change is needed:
Redundant pattern: The try/except blocks were catching exceptions only to log a generic message and re-raise them:
This pattern adds no value since:
Follows Airflow architecture: In Airflow's design pattern:
When Hooks already handle specific error cases gracefully (like
BigtableHook.delete_instance()handlingNotFound), Operators shouldn't duplicate this logic.Code quality: Removing these redundant blocks:
Changes Made
BigtableCreateInstanceOperatorGoogleAPICallErrorBigtableUpdateInstanceOperatorGoogleAPICallErrorBigtableDeleteTableOperatorGoogleAPICallErrorhandler (keptNotFoundhandler for idempotent delete behavior)BigtableUpdateClusterOperatorGoogleAPICallErrorhandler (keptNotFoundhandler for custom error message)Behavioral Changes
No behavioral changes. Exceptions will still propagate correctly - they just won't be caught and immediately re-raised anymore.
Exceptions intentionally kept:
BigtableDeleteTableOperator: KeepsNotFoundhandler to make deletes idempotent (if table doesn't exist, log and continue)BigtableUpdateClusterOperator: KeepsNotFoundhandler to provide a custom, informative error messageBigtableCreateTableOperator: Already had proper handling forAlreadyExistswith validation logicTesting
GoogleAPICallErrorhandlers remainChecklist
For Data Engineering Resume:
This contribution demonstrates: