Skip to content

fix(storage): re-throw upload error after aborting in uploadFileInChunks - #9566

Open
thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/9193-transfer-manager-swallowed-error
Open

thiyaguk09 wants to merge 2 commits into
googleapis:mainfrom
thiyaguk09:fix/9193-transfer-manager-swallowed-error

Conversation

@thiyaguk09

Copy link
Copy Markdown
Contributor

Description

Ensures TransferManager.uploadFileInChunks always rejects with a MultiPartUploadError when a multipart upload fails, even when automatic cleanup (abortUpload) succeeds.

Impact

Prevents silent data loss where failed chunked uploads previously resolved to undefined after aborting the multipart upload, misleading callers into assuming the file upload succeeded.

Changes

  • Removed the early return; statement in uploadFileInChunks after mpuHelper.abortUpload() succeeds so that the original upload error is thrown as a MultiPartUploadError.
  • Preserved both the original upload error message and the abort error message when mpuHelper.abortUpload() also fails.

Testing

  • Updated the existing abortUpload unit test in test/transfer-manager.ts to assert that uploadFileInChunks rejects with the original upload error when abortUpload succeeds.
  • Added a unit test in test/transfer-manager.ts verifying that when both uploadPart and abortUpload fail, the rejected MultiPartUploadError includes both error messages.

Fixes #9193

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Oct 8, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the error handling in TransferManager during multipart upload failures, ensuring that if aborting the upload also fails, a MultiPartUploadError combining both the original error and the abort error is thrown. Unit tests have been updated and added to verify this behavior. Feedback suggests a more defensive approach to extracting error messages from the caught exceptions to avoid potential runtime TypeErrors if the thrown values are not standard Error objects.

Comment thread handwritten/storage/src/transfer-manager.ts
@thiyaguk09
thiyaguk09 marked this pull request as ready for review October 8, 2026 13:14
@thiyaguk09
thiyaguk09 requested review from a team as code owners October 8, 2026 13:14

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TransferManager uploadFileInChunks does not error when aborted

1 participant