Skip to content

Return unexpected EOF if the stream misses its CRC trailer - #78

Merged
klauspost merged 1 commit into
klauspost:masterfrom
forkcloser:master
Oct 12, 2026
Merged

klauspost merged 1 commit into
klauspost:masterfrom
forkcloser:master

Conversation

@apostasie

@apostasie apostasie commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fix #77 and align behavior with go gzip.

Thanks!

Summary by CodeRabbit

  • Bug Fixes
    • Truncated gzip data now reports an unexpected-EOF error when the trailer is missing or incomplete.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b92ee3a5-9394-4c70-9ffe-06b8006345eb

📥 Commits

Reviewing files that changed from the base of the PR and between e1b5b31 and 53d17ef.


📒 Files selected for processing (2)
  • gunzip.go
  • gunzip_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.



📝 Walkthrough

Walkthrough

The gzip reader now returns io.ErrUnexpectedEOF when reading a member’s trailer returns `io.EOF. A regression test checks that truncating the trailer by 1, 7, 8, or 9 bytes produces this error during copying.

Changes

Gzip trailer handling

Layer / File(s) Summary
Report unexpected EOF for truncated trailers
gunzip.go, gunzip_test.go
doReadAhead converts io.EOF during trailer reading to io.ErrUnexpectedEOF. The new test checks several trailer truncation lengths. Other trailer-read errors remain unchanged.

Priority: ⬇️ Low

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 53d17

No actionable merge-blocking risk is identified. Run the regression tests as part of normal checks before merging.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: returning io.ErrUnexpectedEOF when the gzip CRC trailer is missing or truncated.
Linked Issues check Passed Issue #77 requires an unexpected EOF when a gzip member lacks its 8-byte trailer. In Reader.doReadAhead, an io.EOF from io.ReadFull while reading the trailer is now converted to `io.ErrUnexpecte…
Out of Scope Changes check Passed The pull request changes only trailer error handling in gunzip.go and adds focused regression coverage in gunzip_test.go. Both changes directly support Issue #77. No unrelated changes are shown in…

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@apostasie

apostasie commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hey rabbit, can you clarify your Docstring Coverage fail? What would you like me to do here?
@coderabbitai

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
gh api --paginate repos/klauspost/pgzip/issues/78/comments --jq '.[] | select(.body | test("docstring"; "i")) | {user: .user.login, body: .body, url: .html_url}'
gh api --paginate repos/klauspost/pgzip/pulls/78/comments --jq '.[] | select(.body | test("docstring"; "i")) | {user: .user.login, body: .body, path: .path, line: .line, url: .html_url}'
gh pr diff 78 --repo klauspost/pgzip

Length of output: 14199


⚙️ CodeRabbit configuration inspected

Length of output: 97774


🏁 Script executed:

#!/bin/bash
set -euo pipefail
ast-grep outline gunzip.go --match doReadAhead --view expanded
rg -n -B12 -A10 '^func \(z \*Reader\) doReadAhead\(' gunzip.go

Length of output: 939


@apostasie, no documentation change is needed here. The coverage warning appears to be a false positive.

The check reported 50% coverage for the two functions touched by this PR, against an 80% threshold. Both functions already have documentation comments:

  • Reader.doReadAhead in gunzip.go, starting at Line 365.
  • TestTruncatedAtTrailer in gunzip_test.go.

In Go, “docstring” means a documentation comment above the declaration. These comments satisfy that purpose. I cannot determine why the check counted only one.

The check is configured as a warning, not an error. If maintainers want to disable it, they can set reviews.pre_merge_checks.docstrings.mode to "off" in CodeRabbit settings.

You are interacting with an AI system.

@apostasie

Copy link
Copy Markdown
Contributor Author

Thank you rabbit, glad I learned today what a docstring is. Been wondering about that for 25 years now 🤣.

@klauspost

Copy link
Copy Markdown
Owner

@coderabbitai I can't change it, since it is an "Essentials plan feature" 😿

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@klauspost My suggestion was not useful with that plan restriction. No code or documentation change is needed for this PR. You can leave the docstring coverage warning as-is.

You are interacting with an AI system.

@klauspost
klauspost merged commit 172a0d6 into klauspost:master Oct 12, 2026
13 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.

Reader accepts a stream whose 8-byte trailer is missing, skipping the CRC check

2 participants