Skip to content

fix(storage): validate resumable upload session URL origin in REST stub - #16718

Draft
nidhiii-27 wants to merge 1 commit into
mainfrom
fix/storage-resumable-upload-url-validation
Draft

nidhiii-27 wants to merge 1 commit into
mainfrom
fix/storage-resumable-upload-url-validation

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

RestStub now validates that absolute resumable upload session URLs in QueryResumableUpload, DeleteResumableUpload, and UploadChunk match the configured REST endpoint origin (or resolved storage authority with the same scheme) before issuing requests. Relative session paths, custom and emulator endpoints, explicit default ports, and matching origins continue to work unchanged. Added unit tests for resumable upload session URL validation in google/cloud/storage/internal/rest/stub_test.cc.

RestStub now validates that absolute resumable upload session URLs in QueryResumableUpload, DeleteResumableUpload, and UploadChunk match the configured REST endpoint origin (or resolved storage authority with the same scheme) before issuing requests. Relative session paths, custom and emulator endpoints, explicit default ports, and matching origins continue to work unchanged. Added unit tests for resumable upload session URL validation in google/cloud/storage/internal/rest/stub_test.cc.

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 validation for resumable upload session URLs in the REST stub to ensure they match the configured REST endpoint origin or resolved storage authority. It adds helper functions like ParseOrigin and ValidateUploadSessionUrl along with comprehensive unit tests. The reviewer feedback correctly points out that ValidateUploadSessionUrl should be called with the per-call options parameter instead of the class-level options_ member variable in QueryResumableUpload, DeleteResumableUpload, and UploadChunk to ensure per-call option overrides are respected.

Comment on lines +916 to +917
Status valid =
ValidateUploadSessionUrl(request.upload_session_url(), options_);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function should validate the upload session URL against the call-specific options parameter rather than the client-level options_ member variable. This ensures that any per-call option overrides (such as a custom endpoint or authority) are correctly respected during validation.

  Status valid =
      ValidateUploadSessionUrl(request.upload_session_url(), options);

Comment on lines +939 to +940
Status valid =
ValidateUploadSessionUrl(request.upload_session_url(), options_);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function should validate the upload session URL against the call-specific options parameter rather than the client-level options_ member variable. This ensures that any per-call option overrides (such as a custom endpoint or authority) are correctly respected during validation.

  Status valid =
      ValidateUploadSessionUrl(request.upload_session_url(), options);

Comment on lines +960 to +961
Status valid =
ValidateUploadSessionUrl(request.upload_session_url(), options_);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The function should validate the upload session URL against the call-specific options parameter rather than the client-level options_ member variable. This ensures that any per-call option overrides (such as a custom endpoint or authority) are correctly respected during validation.

  Status valid =
      ValidateUploadSessionUrl(request.upload_session_url(), options);

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.04306% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.79%. Comparing base (4a2bfb0) to head (9b9fa81).

Files with missing lines Patch % Lines
google/cloud/storage/internal/rest/stub.cc 98.18% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #16718    +/-   ##
========================================
  Coverage   92.78%   92.79%            
========================================
  Files        2277     2277            
  Lines      228147   228356   +209     
========================================
+ Hits       211696   211907   +211     
+ Misses      16451    16449     -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant