Skip to content

Continue hashing through short stream reads - #679

Merged
ffumero2003 merged 2 commits into
masterfrom
fix-stream-c16-short-read-truncation
Nov 19, 2026
Merged

ffumero2003 merged 2 commits into
masterfrom
fix-stream-c16-short-read-truncation

Conversation

@ffumero2003

Copy link
Copy Markdown
Contributor

Summary

A source that returns fewer bytes than requested before the real end of data could make the checksum and length cover only a prefix, so a truncated body could be uploaded with a matching hash. This continues reading until the requested length or the true end of data.

Changes

  • stream/hashing.py: read until the requested length or true EOF instead of treating a short read as EOF.
  • utils/__init__.py: align the shared helper with the same behavior.
  • Add regression tests for short-read sources.

Verification

  • python -m pytest test/unit — full matrix green (v3 1008, v2 1013, v1 1086, v0 926)
  • Deep SDK panel review: PASS (tier high)

Closes #654

Read nonempty short chunks until the requested length or end of stream.
Append the digest only after end of stream and preserve zero-length reads.

Fixes #654
@ffumero2003 ffumero2003 self-assigned this Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 43 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9a1bed2b-dd0b-4b2f-b53e-3fa28bd5c1a5
Commits

Reviewing files that changed from the base of the PR and between afb0a7d and f49d1e1.

Files selected for processing: 4

  • b2sdk/_internal/stream/hashing.py
  • b2sdk/_internal/utils/__init__.py
  • changelog.d/654.fixed.md
  • test/unit/stream/test_finding_c16_short_reads.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@ffumero2003
ffumero2003 merged commit fc258be into master Nov 19, 2026
29 checks passed
@ffumero2003
ffumero2003 deleted the fix-stream-c16-short-read-truncation branch November 19, 2026 19:37
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.

A short read before end of data makes upload checksum and length cover only a prefix

1 participant