Skip to content

Migrate async client to unified checksum options#3

Open
v-pratap wants to merge 21 commits into
unified-checksum-options-pr1from
unified-checksum-options-pr2
Open

Migrate async client to unified checksum options#3
v-pratap wants to merge 21 commits into
unified-checksum-options-pr1from
unified-checksum-options-pr2

Conversation

@v-pratap

Copy link
Copy Markdown
Owner

Migrates the Async client (connection_impl.cc, object_descriptor_impl.cc) to use the newly introduced unified checksum options. Also includes the necessary fallback logic to support users who are still using the deprecated options.

@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 transitions the asynchronous connection implementation and object descriptors to use the new UploadChecksumValidationOption and DownloadChecksumValidationOption instead of the deprecated EnableCrc32cValidationOption and EnableMD5ValidationOption. Feedback on the changes highlights several issues in the test suite, including redundant duplicate test cases and an incorrect test case expecting an invalid argument when validation is disabled. Additionally, the reviewer noted that the logic for resolving checksum validation options is duplicated across multiple non-test files, violating the repository style guide's recommendation to factor out code duplicated three or more times.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 166 to +180
HashTestCase{StatusCode::kOk,
Options{}
.set<storage::EnableCrc32cValidationOption>(true)
.set<storage::EnableMD5ValidationOption>(false),
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kCrc32c),
kQuickFoxCrc32cChecksum, kQuickFoxMD5HashBad},
HashTestCase{StatusCode::kOk,
Options{}
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kMD5),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5Hash},
HashTestCase{StatusCode::kOk,
Options{}
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kNone),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},

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

These three test cases are completely duplicated and identical to the three test cases immediately following them (lines 181-195). Please remove this redundant block.

Comment on lines 198 to 222
HashTestCase{StatusCode::kInvalidArgument,
Options{}
.set<storage::EnableCrc32cValidationOption>(false)
.set<storage::EnableMD5ValidationOption>(true),
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kMD5),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},
HashTestCase{StatusCode::kInvalidArgument,
Options{}
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kCrc32c),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},
HashTestCase{StatusCode::kInvalidArgument,
Options{}
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kNone),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},
HashTestCase{StatusCode::kInvalidArgument,
Options{}
.set<storage::EnableCrc32cValidationOption>(true)
.set<storage::EnableMD5ValidationOption>(false),
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kCrc32c),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},
HashTestCase{StatusCode::kInvalidArgument,
Options{}
.set<storage::EnableCrc32cValidationOption>(true)
.set<storage::EnableMD5ValidationOption>(true),
.set<storage::DownloadChecksumValidationOption>(
storage::ChecksumAlgorithm::kMD5),
kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},

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

This block of kInvalidArgument test cases contains several issues:

  1. The test case with storage::ChecksumAlgorithm::kNone (lines 208-212) expects StatusCode::kInvalidArgument. However, when validation is disabled (kNone), no validation is performed, so it should succeed with StatusCode::kOk (which is already tested in the kOk section). This test case is incorrect and will fail.
  2. The test cases for kCrc32c and kMD5 are duplicated (lines 213-217 and 218-222 are duplicates of lines 203-207 and 198-202 respectively).

Please simplify this block to only include the two unique and correct test cases for kMD5 and kCrc32c validation failures.

        HashTestCase{StatusCode::kInvalidArgument,
                     Options{}
                         .set<storage::DownloadChecksumValidationOption>(
                             storage::ChecksumAlgorithm::kMD5),
                     kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},
        HashTestCase{StatusCode::kInvalidArgument,
                     Options{}
                         .set<storage::DownloadChecksumValidationOption>(
                             storage::ChecksumAlgorithm::kCrc32c),
                     kQuickFoxCrc32cChecksumBad, kQuickFoxMD5HashBad},

Comment on lines +85 to +95
bool enable_crc32c = false;
bool enable_md5 = false;

if (options.has<storage::UploadChecksumValidationOption>()) {
auto const algo = options.get<storage::UploadChecksumValidationOption>();
enable_crc32c = (algo == storage::ChecksumAlgorithm::kCrc32c);
enable_md5 = (algo == storage::ChecksumAlgorithm::kMD5);
} else {
enable_crc32c = options.get<storage::EnableCrc32cValidationOption>();
enable_md5 = options.get<storage::EnableMD5ValidationOption>();
}

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

The logic to resolve the checksum validation options is duplicated here and in CreateHashValidator (lines 132-142), as well as in object_descriptor_impl.cc. According to the repository style guide (lines 28-29), we should prefer to factor out duplicated code if it appears 3 or more times in non-test files. Consider defining a helper function template to handle both upload and download options:

template <typename Option>
std::pair<bool, bool> GetChecksumSettings(Options const& options) {
  if (options.has<Option>()) {
    auto const algo = options.get<Option>();
    return {algo == storage::ChecksumAlgorithm::kCrc32c,
            algo == storage::ChecksumAlgorithm::kMD5};
  }
  return {options.get<storage::EnableCrc32cValidationOption>(),
          options.get<storage::EnableMD5ValidationOption>()};
}

And then use structured bindings:

auto const [enable_crc32c, enable_md5] = GetChecksumSettings<storage::UploadChecksumValidationOption>(options);
References
  1. Prefer to factor out duplicated code if it appears 3 or more times in non-test files. (link)

Comment on lines +225 to +234
bool enable_crc32c = false;
bool enable_md5 = false;
if (options_.has<storage::DownloadChecksumValidationOption>()) {
auto const algo = options_.get<storage::DownloadChecksumValidationOption>();
enable_crc32c = (algo == storage::ChecksumAlgorithm::kCrc32c);
enable_md5 = (algo == storage::ChecksumAlgorithm::kMD5);
} else {
enable_crc32c = options_.get<storage::EnableCrc32cValidationOption>();
enable_md5 = options_.get<storage::EnableMD5ValidationOption>();
}

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

The logic to resolve the download checksum validation options is duplicated here and in CreateHashValidator (lines 266-275), as well as in connection_impl.cc. According to the repository style guide (lines 28-29), we should prefer to factor out duplicated code if it appears 3 or more times in non-test files. Consider factoring this out into a helper function (e.g., in an anonymous namespace or as a private helper method):

std::pair<bool, bool> GetDownloadChecksumSettings(Options const& options) {
  if (options.has<storage::DownloadChecksumValidationOption>()) {
    auto const algo = options.get<storage::DownloadChecksumValidationOption>();
    return {algo == storage::ChecksumAlgorithm::kCrc32c,
            algo == storage::ChecksumAlgorithm::kMD5};
  }
  return {options.get<storage::EnableCrc32cValidationOption>(),
          options.get<storage::EnableMD5ValidationOption>()};
}

And then use structured bindings:

auto const [enable_crc32c, enable_md5] = GetDownloadChecksumSettings(options_);
References
  1. Prefer to factor out duplicated code if it appears 3 or more times in non-test files. (link)

@v-pratap
v-pratap force-pushed the unified-checksum-options-pr1 branch from 1264fa0 to 55ceb4c Compare July 15, 2026 09:28
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 23658d1 to bc369e7 Compare July 15, 2026 09:28
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr1 branch from 55ceb4c to 6580fd9 Compare July 15, 2026 10:15
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from bc369e7 to 9ed6fe1 Compare July 15, 2026 10:15
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 9ed6fe1 to 2799489 Compare July 15, 2026 10:27
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr1 branch from 6580fd9 to 6c92722 Compare July 15, 2026 10:52
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 2799489 to 67305d6 Compare July 15, 2026 10:53
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 67305d6 to 8bd3544 Compare July 15, 2026 10:56
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 8bd3544 to 1268c7f Compare July 15, 2026 11:27
@v-pratap
v-pratap force-pushed the unified-checksum-options-pr2 branch from 59e1bf1 to c0cf77b Compare July 17, 2026 09:17
@v-pratap
v-pratap deployed to internal July 17, 2026 10:42 — with GitHub Actions Active
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.

5 participants