fix(gax): propagate chunk granularity on resume and preserve retry error details - #9480
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the ResumableUploadSession to support chunk granularity during resumable uploads, ensuring that chunk sizes are properly aligned with the server's requirements during recovery queries and session starts. It also improves error handling by propagating underlying error messages when retries are exhausted and throwing a TransientError when start headers are missing. The feedback suggests defensively checking the type of the caught error before accessing its .message property to prevent potential runtime TypeErrors when formatting error messages.
quirogas
left a comment
There was a problem hiding this comment.
Reviewed the changes and ran local empirical tests against the new granularity propagation and retry error handling paths. Left a few inline comments on edge cases we reproduced.
Summary
Improves
ResumableUploadSessionhandling of server-specified chunk granularity during session start, recovery queries, and resumption, and preserves underlying failure details when retries are exhausted:x-goog-upload-chunk-granularity):x-goog-upload-chunk-granularityinqueryOffset()and propagate it when resuming viaresumeUrl, reconcilingstartresponses, or recovering mid-transfer.effectiveChunkSize_before invokingreportProgress()duringstart()sosession.chunkSizereflects the negotiated chunk size insideonProgresscallbacks from the very first progress event.effectiveChunkSize_than the non-final chunk currently in flight, restart transmission fromserverOffsetwith the aligned chunk size.startwhen bothx-goog-upload-statusandx-goog-upload-urlare missing:startresponse omitsx-goog-upload-statusand has nox-goog-upload-urlto reconcile viaquery, classify it as aTransientErrorsostartretries with backoff.sendCommandWithRetry,transmitChunk, ortransmitFinalizeexhaustsmaxRetries, and avoid double-wrappingTransientErrorinfetchCommand.gapic-showcasechunk_granularitypause-and-resume test scenario.