Skip to content

feat(storage): migrate sync client to unified checksum options#16264

Open
v-pratap wants to merge 9 commits into
googleapis:mainfrom
v-pratap:unified-checksum-options-pr3
Open

feat(storage): migrate sync client to unified checksum options#16264
v-pratap wants to merge 9 commits into
googleapis:mainfrom
v-pratap:unified-checksum-options-pr3

Conversation

@v-pratap

Copy link
Copy Markdown
Contributor

Migrates the Sync client to use the newly introduced unified checksum options. Also includes the necessary fallback logic to support users who are still using the deprecated options.

Note: This PR is stacked on top of #16261 and includes its commits. It should be merged after #16261.

@v-pratap v-pratap requested review from a team as code owners July 16, 2026 13:15
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Jul 16, 2026
@v-pratap v-pratap added the do not review Indicates a PR is not ready for review label Jul 16, 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 UploadChecksumValidationOption and DownloadChecksumValidationOption using a new ChecksumAlgorithm enum to replace several deprecated checksum options and classes. It updates internal hash functions, validators, and tests to support these new options. The review feedback highlights that using the deprecated types in hash_function.cc, hash_validator.cc, and object_requests.cc will trigger -Wdeprecated-declarations compiler warnings, suggesting the inclusion of deprecation warning disable headers. Additionally, the reviewer recommends refactoring duplicated fallback logic for resolving checksum settings into a shared helper function to align with the repository style guide.

Comment on lines +17 to +18
#include "google/cloud/options.h"
#include "google/cloud/storage/options.h"

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

Using the deprecated types DisableCrc32cChecksum and DisableMD5Hash in this file will trigger -Wdeprecated-declarations compiler warnings (which are treated as errors in builds with -Werror). Although hash_function.h disables deprecation warnings, it pops the diagnostics at the end of the header, meaning the warnings are re-enabled when compiling this .cc file. Please include disable_deprecation_warnings.inc at the top of this file and remember to add #include "google/cloud/internal/diagnostics_pop.inc" at the very end of the file.

#include "google/cloud/options.h"
#include "google/cloud/storage/options.h"
#include "google/cloud/internal/disable_deprecation_warnings.inc"

Comment on lines +17 to +18
#include "google/cloud/options.h"
#include "google/cloud/storage/options.h"

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

Using the deprecated types DisableCrc32cChecksum and DisableMD5Hash in this file will trigger -Wdeprecated-declarations compiler warnings (which are treated as errors in builds with -Werror). Please include disable_deprecation_warnings.inc at the top of this file and remember to add #include "google/cloud/internal/diagnostics_pop.inc" at the very end of the file.

#include "google/cloud/options.h"
#include "google/cloud/storage/options.h"
#include "google/cloud/internal/disable_deprecation_warnings.inc"

Comment on lines +17 to +18
#include "google/cloud/storage/options.h"
#include "google/cloud/options.h"

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

Using the deprecated types DisableCrc32cChecksum and DisableMD5Hash in this file will trigger -Wdeprecated-declarations compiler warnings (which are treated as errors in builds with -Werror). Although object_requests.h disables deprecation warnings, it pops the diagnostics at the end of the header, meaning the warnings are re-enabled when compiling this .cc file. Please include disable_deprecation_warnings.inc at the top of this file and remember to add #include "google/cloud/internal/diagnostics_pop.inc" at the very end of the file.

#include "google/cloud/storage/options.h"
#include "google/cloud/options.h"
#include "google/cloud/internal/disable_deprecation_warnings.inc"

Comment on lines +66 to +76
bool disable_md5 = false;
bool disable_crc32c = false;
auto const& options = google::cloud::internal::CurrentOptions();
if (options.has<DownloadChecksumValidationOption>()) {
auto const algo = options.get<DownloadChecksumValidationOption>();
disable_md5 = (algo != ChecksumAlgorithm::kMD5);
disable_crc32c = (algo != ChecksumAlgorithm::kCrc32c);
} else {
disable_md5 = request.GetOption<DisableMD5Hash>().value_or(false);
disable_crc32c = request.GetOption<DisableCrc32cChecksum>().value_or(false);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This fallback logic for resolving download checksum settings is duplicated across multiple files (e.g., in hash_validator.cc for both download and upload requests). Per the repository style guide, we should prefer to factor out duplicated code if it appears 3 or more times in non-test files. Consider defining a shared helper function (e.g., GetDownloadChecksumSettings and GetUploadChecksumSettings overloads that accept a request and options) in a common internal header like google/cloud/storage/internal/hash_function.h to centralize this logic and reduce duplication.

References
  1. Prefer to factor out duplicated code if it appears 3 or more times in non-test files. (link)

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.48649% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.26%. Comparing base (e493b2d) to head (d2b9add).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
google/cloud/storage/internal/hash_function.cc 70.00% 6 Missing ⚠️
google/cloud/storage/internal/hash_validator.cc 66.66% 6 Missing ⚠️
google/cloud/storage/internal/object_requests.cc 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16264      +/-   ##
==========================================
- Coverage   92.27%   92.26%   -0.01%     
==========================================
  Files        2214     2215       +1     
  Lines      206505   206582      +77     
==========================================
+ Hits       190556   190609      +53     
- Misses      15949    15973      +24     

☔ 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.

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. do not review Indicates a PR is not ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant