Skip to content

feat(Storage)!: Enable full object checksum validation for resumable uploads - #15769

Draft
mahendra-google wants to merge 1 commit into
googleapis:mainfrom
mahendra-google:feature/enable-full-object-checksum
Draft

feat(Storage)!: Enable full object checksum validation for resumable uploads#15769
mahendra-google wants to merge 1 commit into
googleapis:mainfrom
mahendra-google:feature/enable-full-object-checksum

Conversation

@mahendra-google

Copy link
Copy Markdown
Contributor

This PR transitions upload object checksum integrity validation from client-side to the server-side.

Previously, CRC32C validation occurred after the upload is completed, requiring the client to delete the object (using DeleteAndThrow upload validation mode) or leave a corrupted object in the bucket (using ThrowOnly upload validation mode) upon hash mismatches. By leveraging the new LastRequestExecuting event in google-api-dotnet-client core library, this implementation calculates CRC32C incrementally during streaming and injects the x-goog-hash: crc32c=... header on the final chunk. If a checksum mismatch occurs, the server rejects the upload with an HTTP 400 Bad Request, ensuring invalid objects are never created in the bucket.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 20, 2026

@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 updates the upload validation mechanism in the Google Cloud Storage V1 client. It introduces UploadValidationMode.RejectAndThrow to allow the server to reject mismatched objects before creation, deprecates UploadValidationMode.DeleteAndThrow, and removes UploadValidationMode.ThrowOnly along with the UploadValidationException class. It also introduces a HashingStream within CustomMediaUpload to calculate CRC32C hashes on the fly and inject the x-goog-hash header. The feedback highlights that removing ThrowOnly and UploadValidationException are breaking changes for existing client applications, and recommends restoring them with an [Obsolete] attribute to maintain backward compatibility.

I am having trouble creating individual review comments. Click here to see my feedback.

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/UploadValidationMode.cs (29-35)

high

Removing ThrowOnly from the UploadValidationMode enum is a breaking change for existing client applications. To maintain backward compatibility, please restore ThrowOnly and mark it as [Obsolete], mapping it to the new validation behavior.

        /// <summary>
        /// Obsolete. Use <see cref="RejectAndThrow"/> instead.
        /// Previously, the hash of the data was computed while uploading, and if the resulting object had a different hash, an exception was thrown, but the object remained present in Storage.
        /// </summary>
        [Obsolete("ThrowOnly is deprecated. Use RejectAndThrow instead, as the server now rejects the object before creation.")]
        ThrowOnly = 1,

        /// <summary>
        /// Obsolete. Use <see cref="RejectAndThrow"/> instead.
        /// Previously, the object was uploaded and then deleted if the hash mismatched. 
        /// The server now rejects mismatched objects automatically before creation.
        /// </summary>
        [Obsolete("DeleteAndThrow is deprecated. Use RejectAndThrow instead, as the server now rejects the object before creation.")]
        DeleteAndThrow = 2,

apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/UploadValidationException.cs (23-26)

high

Removing the public class UploadValidationException is a breaking change for existing client applications that catch this exception.

To maintain backward compatibility, please restore this class and mark it as [Obsolete]. This allows existing code to compile with a warning rather than failing with a compilation error.

@mahendra-google mahendra-google changed the title feat(Storage): Enable full object checksum validation for resumable uploads feat(Storage)!: Enable full object checksum validation for resumable uploads Jul 22, 2026
@mahendra-google
mahendra-google marked this pull request as ready for review July 30, 2026 06:14
@mahendra-google
mahendra-google requested review from a team as code owners July 30, 2026 06:14
@amanda-tarafa

Copy link
Copy Markdown
Contributor

Let's keep this one in draft until we have updated the core libraries to the newest dependency.

@amanda-tarafa
amanda-tarafa marked this pull request as draft August 4, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants