Skip to content

feat(storage): enable default CRC32C checksum validation for object downloads#7

Merged
salilg-eng merged 1 commit into
mainfrom
feat/default-crc32c
May 25, 2026
Merged

feat(storage): enable default CRC32C checksum validation for object downloads#7
salilg-eng merged 1 commit into
mainfrom
feat/default-crc32c

Conversation

@salilg-eng
Copy link
Copy Markdown
Owner

Overview

Enables full object checksum validation (CRC32C by default) across GCS JSON read paths, covering all four download methods: downloadAsString, downloadToFile, downloadAsStream, and downloadAsStreamAsync.

It integrates a HashValidatingStream decorator that computes hashes on-the-fly and validates them upon reaching the end of the stream.

Key Features

  • CRC32C by Default: Prioritizes lightweight, hardware-accelerated CRC32C validation.
  • MD5 Fallback: Automatically falls back to validating MD5 if a CRC32C hash is not available on the GCS object.
  • Configurable Options: Supports user overrides through the 'validate' parameter (crc32, md5, or false to disable).
  • Subrange Bypass: Bypasses checks automatically on partial range downloads (HTTP 206 Partial Content) where full object validation is incompatible.

Buganizer Tasks Resolved

  • Fixes b/514548528 ([PHP] SDK: Full object checksum for all JSON and XML Reads as well)

Testing

  • Added new unit tests in HashValidatingStreamTest.php.
  • Added sync/async integration test cases inside RestTest.php.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a 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 implements on-the-fly hash validation for object downloads using a new HashValidatingStream decorator. The Rest connection class is updated to wrap download streams and validate them against CRC32C or MD5 headers. Feedback identifies a potential issue where seeking on the decorated stream could corrupt hash calculations, suggesting that seeking should be explicitly disabled in the HashValidatingStream class.

Comment thread Storage/src/HashValidatingStream.php
@salilg-eng salilg-eng force-pushed the feat/default-crc32c branch 3 times, most recently from 04cc1dd to fa77863 Compare May 25, 2026 07:35
@salilg-eng salilg-eng force-pushed the feat/default-crc32c branch from fa77863 to d52e22f Compare May 25, 2026 07:38
@salilg-eng salilg-eng marked this pull request as ready for review May 25, 2026 09:07
@salilg-eng salilg-eng merged commit 55ab046 into main May 25, 2026
27 checks passed
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.

3 participants