You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
storage: AsyncMultiRangeDownloader loses object metadata when initial open is redirected with a read_handle #19134
When AsyncMultiRangeDownloader.create_mrd(..., read_handle=None) (or open() without a caller-supplied read_handle) receives an AbortedBidiReadObjectRedirectedError carrying both routing_token and read_handle, AsyncMultiRangeDownloader._on_open_error() unconditionally adopts redirect.read_handle and retries open() with BidiReadObjectSpec.read_handle set.
Per google/storage/v2/storage.proto, BidiReadObjectResponse.metadata is not populated when a stream is opened with a read_handle. As a result, create_mrd() returns with persisted_size=None, is_finalized=False, full_obj_server_crc32c=None, and generation=None (when generation was not passed), even though the caller did not supply a read_handle. Callers that rely on persisted_size—for example when reading an unfinalized appendable object whose live size is not yet reflected elsewhere—receive None.
Expected behavior
When opening without a caller-supplied read_handle, a redirect that includes a routing_token should retry with the routing_token only so the initial response includes BidiReadObjectResponse.metadata (populating persisted_size, is_finalized, full_obj_server_crc32c, and generation) along with a fresh read_handle for subsequent streams.
Proposed fix
In AsyncMultiRangeDownloader._on_open_error(), only adopt redirect.read_handle if self.read_handle is already set (caller supplied a handle or a handle was already obtained) or the redirect has no routing_token. Otherwise retry with routing_token alone.
Activity