Skip to content

feat(gax): standardize mapping terminal resumable upload exceptions to ApiException - #14624

Open
whowes wants to merge 1 commit into
mainfrom
whowes/resumable-upload-errors
Open

whowes wants to merge 1 commit into
mainfrom
whowes/resumable-upload-errors

Conversation

@whowes

@whowes whowes commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
  • Local failures (IOException, IllegalStateException, etc.) are now wrapped in UnknownException with the original exception as getCause(), matching GAX's usual convention (e.g. HttpJsonApiExceptionFactory).
  • Removed manual URL suffixes from ResumableUploadChunkCoordinator and onTimeout(); toTerminalException now appends the session URL (when available) at the future boundary.
  • closePayload(@Nullable Throwable) now attaches any payload.close() failure via addSuppressed() instead of swallowing it.

@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 refactors resumable upload error handling by removing the upload URL from RewindableStreamBuffer and centralizing exception formatting in ResumableUploadFutureImpl.toTerminalException. It also improves stream cleanup by propagating suppressed exceptions during payload closure. The review feedback highlights two important improvements: adding a null check in toTerminalException to prevent a potential NullPointerException when the input exception is null, and narrowing the caught exception type in closePayload from Throwable to Exception to avoid intercepting critical JVM errors.

@whowes
whowes force-pushed the whowes/resumable-upload-errors branch 2 times, most recently from 95bf1aa to 461fc12 Compare October 10, 2026 00:14
@whowes
whowes force-pushed the whowes/resumable-upload-errors branch from 461fc12 to 7c2dd99 Compare October 12, 2026 18:26
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@whowes
whowes marked this pull request as ready for review October 12, 2026 18:36
@whowes
whowes requested a review from a team as a code owner October 12, 2026 18:36
@whowes
whowes requested a review from blakeli0 October 12, 2026 18:36
}
String message = firstNonNull(t.getMessage(), t.getClass().getSimpleName());
if (uploadSessionUrl != null) {
message = message + " (upload URL: " + uploadSessionUrl + ")";

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.

We might missed this in previous PRs. I think the upload URL contains an upload id, and anyone with the id can upload without authentication? If that's the case, I think it would be better to not include the full url in the log.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This did come up in an earlier PR - revisiting this I think that we're required to surface the full URL. From internal cross-language design docs:

"The Client Libraries should include the upload URL as part of the errors it returns to the end-user when resumable upload-related errors occur."

and

"The upload URL can be configured (in the server configuration) to be completely arbitrary, so we cannot guarantee that we can parse the upload ID. The URL will have to be surfaced in its entirety."

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants