Conversation
upload_file()'s `except BaseException` handler cleans up both the raw download and the converted parquet, but only parquet_file was pre-initialised. raw_path is first bound at the `_download_raw_with_retry` call, so any failure raised before that point made the handler itself raise `UnboundLocalError: cannot access local variable 'raw_path'`. That replaced the real exception with a misleading message, since `_reprocess` surfaces whatever the handler propagates — the operator saw "cannot access local variable 'raw_path'" instead of the actual cause. The temp file was also orphaned, as the cleanup aborted before running. Both names are now bound to None before the try block and the handler guards on raw_path, matching the existing parquet_file handling. Failures before the download now propagate their original type and message. Tests cover both paths: an error raised by _ensure_management_columns (before the download) propagates unchanged, and an error raised while hashing the download (after it) still removes the temp file.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #369 +/- ##
=======================================
Coverage ? 97.20%
=======================================
Files ? 180
Lines ? 23310
Branches ? 0
=======================================
Hits ? 22659
Misses ? 651
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
fix(sync): avoid UnboundLocalError in the upload_file error handler
upload_file()'s
except BaseExceptionhandler cleans up both the rawdownload and the converted parquet, but only parquet_file was
pre-initialised. raw_path is first bound at the
_download_raw_with_retrycall, so any failure raised before that point made the handler itself
raise
UnboundLocalError: cannot access local variable 'raw_path'.That replaced the real exception with a misleading message, since
_reprocesssurfaces whatever the handler propagates — the operator saw"cannot access local variable 'raw_path'" instead of the actual cause.
The temp file was also orphaned, as the cleanup aborted before running.
Both names are now bound to None before the try block and the handler
guards on raw_path, matching the existing parquet_file handling. Failures
before the download now propagate their original type and message.
Tests cover both paths: an error raised by _ensure_management_columns
(before the download) propagates unchanged, and an error raised while
hashing the download (after it) still removes the temp file.
This is a re-submission of #350, which was closed without review. The
workflow runs on that PR sat in
action_requiredfor three days and thenexpired unapproved, so CI never went green.
The fix is unchanged; the branch was rebased onto the current
main, wherethe suite passes (1780 passed, 6 skipped) and black/isort/flake8 are clean.