GeezerVison is showing github.com — feat(storage): Enable full object checksum PR 1/3 : parse finalize_time and server crc32c in async object stream by chandra-siri · Pull Request #17261 · googleapis/google-cloud-python
Conversation
1. Overview of the Solution
This solution implements end-to-end full-object checksum validation in AsyncMultiRangeDownloader for the asynchronous Google Cloud Storage Python client library. As asynchronous multiplexed downloads of non-contiguous ranges are performed concurrently over a single bidirectional gRPC connection, this feature automatically and incrementally calculates a rolling checksum as bytes arrive and validates it against the server's authoritative object checksum once the download completes.
The technical approach consists of three coordinated layers:
_AsyncReadObjectStream (Stream Ingestion): Safely extracts the authoritative server checksum (full_obj_server_crc32c) and finalization status (is_finalized) from the object metadata received in the first data payload response of the stream.
_ReadResumptionStrategy & _DownloadState (Verification Logic): Computes an isolated, persistent rolling checksum in the individual _DownloadState object to ensure calculations do not bleed across concurrent multiplexed ranges. Crucially, the rolling hash updates only after buffer writes succeed to prevent state corruption during retry re-connects, raising a DataCorruption exception on completion if a mismatch occurs.
AsyncMultiRangeDownloader (Orchestration & Cleanup): Detects candidate full-object ranges (e.g., (0, 0) or (0, persisted_size)), propagates checksum settings to the resumption strategy, and guarantees robust cleanup (closing the stream immediately and unregistering IDs) if data corruption or write errors occur.
2. What This PR Specifically Does
This PR implements Step 1: Stream Metadata Ingestion of the solution:
- Modifies
_AsyncReadObjectStream to safely parse GCS object metadata from the first data payload of the response.
- Populates
is_finalized, full_obj_server_crc32c, and object_metadata attributes in _AsyncReadObjectStream.open().
- Adds an autouse pytest event loop fixture in
tests/unit/conftest.py to resolve compatibility issues with pytest-asyncio under Python 3.11+.
- Adds unit tests in
test_async_read_object_stream.py to verify that finalization status and server-authoritative checksums are correctly extracted or skipped for unfinalized objects.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
gemini-code-assist[bot] reacted with eyes emoji
There was a problem hiding this comment.
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 introduces tracking for object finalization and full object CRC32C checksums in the asynchronous read stream. The feedback focuses on simplifying the production code by removing logic added solely to accommodate unit test mocks (such as checking for a .seconds attribute). Instead, it is recommended to mock finalize_time as a standard datetime.datetime or None in the unit tests, which allows the production code to rely on standard isinstance checks.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
chandra-siri
changed the title
feat(storage): parse finalize_time and server crc32c in async object stream
feat(storage): full object checksum: parse finalize_time and server crc32c in async object stream
May 26, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
chandra-siri
changed the title
feat(storage): full object checksum: parse finalize_time and server crc32c in async object stream
feat(storage): Enable full object checksum PR 1/3 : parse finalize_time and server crc32c in async object stream
Jun 4, 2026
Uh oh!
There was an error while loading. Please reload this page.
parthea
added a commit
that referenced
this pull request
Aug 14, 2026
…17411)
This PR exposes the `object_metadata` attribute on the
`AsyncMultiRangeDownloader` class.
### Context
In PR #17261, `object_metadata` was successfully exposed on the
`AsyncReadObjectStream`. However, it was not surfaced on the
`AsyncMultiRangeDownloader` (MRD), meaning high-level libraries relying
on MRD (like `fsspec`/`gcsfs`) cannot access the underlying gRPC
metadata.
By inheriting and surfacing `self.object_metadata =
self.read_obj_str.object_metadata`, this allows downstream users to
completely bypass redundant `REST` `info()` API calls and extract fields
like `crc32c`, `size`, and `generation` directly from the MRD instance.
cc @chandra-siri
---------
Co-authored-by: Anthonios Partheniou <[email protected]>
Reviewers
v-pratap
Awaiting requested review from v-pratap
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|