Skip to content

[Backport v2] fix(content): report a failed read after the content as that error - #1655

Merged
TerryHowe merged 1 commit into
oras-project:v2from
jadhavgaurav:fix/verifyreader-read-error-v2
Oct 21, 2026
Merged

TerryHowe merged 1 commit into
oras-project:v2from
jadhavgaurav:fix/verifyreader-read-error-v2

Conversation

@jadhavgaurav

Copy link
Copy Markdown
Contributor

Backport of #1648 to v2.

ensureEOF returned ErrTrailingData for any non-EOF result of the probe read, so a source failing after all declared bytes (for example an unexpected EOF on a truncated chunked response) was not matchable with errors.Is(err, io.ErrUnexpectedEOF). It now returns ErrTrailingData only when the probe read a byte, and wraps other errors as read failed: %w.

The diff of #1648 applied to v2 without changes, including the new case in TestVerifyReader_Verify. The new case fails on unfixed v2 (Verify() error = trailing data) and passes with the fix. go vet, gofmt, go test -race ./content/... and go test ./... pass.

Fixes #1649

Backport of oras-project#1648 to v2. ensureEOF returned ErrTrailingData for any
non-EOF result of the probe read. Return it only when the probe read a
byte, and report other read errors as "read failed: %w" so callers can
match errors such as io.ErrUnexpectedEOF.

Signed-off-by: Gaurav Jadhav <gaurav.vjadhav01@gmail.com>
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

โœ… All modified and coverable lines are covered by tests.
โœ… Project coverage is 89.08%. Comparing base (4a7fcac) to head (ae0f26b).

Additional details and impacted files
@@            Coverage Diff             @@
##               v2    #1655      +/-   ##
==========================================
- Coverage   89.22%   89.08%   -0.14%     
==========================================
  Files          65       65              
  Lines        5030     5032       +2     
==========================================
- Hits         4488     4483       -5     
- Misses        533      540       +7     
  Partials        9        9              

โ˜” 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.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe
TerryHowe merged commit fbc1ece into oras-project:v2 Oct 21, 2026
9 checks passed
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.

2 participants