Skip to content

feat(storage): add full object checksum validation for bidi flow#13266

Open
Dhriti07 wants to merge 1 commit into
add-cumulative-hasher-grpc-flowfrom
add-cumulative-hasher-bidi-flow
Open

feat(storage): add full object checksum validation for bidi flow#13266
Dhriti07 wants to merge 1 commit into
add-cumulative-hasher-grpc-flowfrom
add-cumulative-hasher-bidi-flow

Conversation

@Dhriti07
Copy link
Copy Markdown
Contributor

Adding full object checksum for bidi flow

Refer to: go/full_checksum_java

@Dhriti07 Dhriti07 requested review from a team as code owners May 25, 2026 15:30
Copy link
Copy Markdown
Contributor

@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 cumulative checksum validation for full object reads within the ObjectReadSessionStream. It introduces a CumulativeHasher that is conditionally applied in BaseObjectReadSessionStreamRead and validated in ObjectReadSessionStream upon completion. The changes also include extensive unit tests covering success and failure cases for single and multi-chunk reads. Feedback suggests refining the logic for enabling the CumulativeHasher; currently, it activates for any read starting at offset 0, which could incorrectly include partial reads. It is recommended to use rangeSpec.isAll() to restrict this validation strictly to full object reads.

Comment on lines +153 to +156
this.hasher =
(rangeSpec.begin() == 0)
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;
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.

medium

The condition rangeSpec.begin() == 0 is too broad for full object checksum validation. It will trigger for any partial read that starts at the beginning of the object (e.g., reading only the first 100 bytes). This results in unnecessary overhead and potential validation failures if the hasher attempts to compare a partial range's checksum against the full object's checksum. Consider using rangeSpec.isAll() to ensure validation is only enabled for full object reads.

Suggested change
this.hasher =
(rangeSpec.begin() == 0)
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;
this.hasher =
rangeSpec.isAll()
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;

Comment on lines +286 to +289
this.hasher =
(rangeSpec.begin() == 0)
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;
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.

medium

Similar to the AccumulatingRead constructor, using rangeSpec.begin() == 0 here will enable CumulativeHasher for partial reads starting at offset 0. It is better to use rangeSpec.isAll() to target only full object reads.

Suggested change
this.hasher =
(rangeSpec.begin() == 0)
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;
this.hasher =
rangeSpec.isAll()
? new CumulativeHasher(hasher, 0, rangeSpec.maxLength())
: hasher;

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.

1 participant