-
Notifications
You must be signed in to change notification settings - Fork 248
fix(puffin): surface LZ4 content-checksum error regardless of JSON decoder read-ahead #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -502,6 +502,10 @@ func (r *Reader) readFooter() error { | |
| return fmt.Errorf("puffin: read buffered footer JSON: %w", err) | ||
| } | ||
| if len(bytes.TrimSpace(buffered)) > 0 { | ||
| if compressedFooter != nil && compressedFooter.err != nil { | ||
| return fmt.Errorf("puffin: read compressed footer: %w", compressedFooter.err) | ||
| } | ||
|
|
||
| return errors.New("puffin: unexpected content after footer JSON") | ||
| } | ||
| } | ||
|
|
@@ -510,6 +514,10 @@ func (r *Reader) readFooter() error { | |
| // content deliberately, even though some other Iceberg implementations | ||
| // accept padding or additional values inside the footer payload. | ||
| if decoder.More() { | ||
| if compressedFooter != nil && compressedFooter.err != nil { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neither of these new branches is exercised by the current test. |
||
| return fmt.Errorf("puffin: read compressed footer: %w", compressedFooter.err) | ||
| } | ||
|
|
||
| return errors.New("puffin: unexpected content after footer JSON") | ||
| } | ||
| if _, err := decoder.Token(); !errors.Is(err, io.EOF) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checksum error only survives if every trailing-content return remembers to check
compressedFooter.err, and we've now had to patch that in after the fact twice. Add a fourth trailing-content return down the line and it silently drops the error again, which is the exact regression this PR is closing. I'd move the check to a single site right afterDecodereturns nil, before any of the trailing-content logic, so it's structural instead of something each new return has to remember. A smallcheckCompressedFooterErr(compressedFooter)helper is a fine alternative if you'd rather keep the per-site shape.Minor and moot if you collapse to the single check: inside this
limitedFooter != nil && N == 0branchcompressedFooteris always non-nil (both are only set past the compressed-footer gate), so the!= nilarm here is dead; it's only load-bearing at the sites outside that branch.