fix(image): dead code, FormatBytes safety, and Truncated for daemon extraction - #104
Merged
Merged
Conversation
…xtraction - Remove ErrNoEngineFound.Cause and Unwrap(): the field was never set at either construction site, making Unwrap() always return nil. Callers match on the type, not the wrapped cause, so removing it makes the interface honest without breaking anything. - Guard FormatBytes against negative int64 inputs: the uint64 cast silently wrapped negatives to large positive values. Current callers pass non-negative sizes, but the contract was invisible. Returns a sign-prefixed string for negative inputs, consistent with FormatSignedBytes. - Fix Truncated flag suppression in DockerExtractor.Extract: readFirstFileFromTar truncated the stream to MaxViewSize before returning, so processContent always saw len(data) <= MaxViewSize and never set fc.Truncated. Now returns the declared tar header size alongside the data; the caller passes the larger of the stat size and the header size to processContent so the truncated notice is shown when a daemon-extracted file exceeds 1 MB. - Remove stale internal-docs reference from compare_regression_test.go: the file is gitignored and absent from a clean clone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ErrNoEngineFound.Cause/Unwrap()removed — the field was never set at either construction site, soUnwrap()always returnednil. Callers match on the type directly; removing the dead field makes the interface honest.FormatBytesnegative-input guard — theuint64cast silently wrapped negativeint64values to large positive values. Now returns a sign-prefixed string for negative inputs, consistent withFormatSignedBytes.Truncatedflag fixed for daemon extraction —readFirstFileFromTartruncated the stream toMaxViewSizebefore returning, soprocessContentalways sawlen(data) <= MaxViewSizeand never setfc.Truncated. The function now returns the declared tar header size; the caller passes the larger of the stat size and the header size toprocessContentso the truncation notice is shown correctly for files > 1 MB.internal-docscomment removed fromcompare_regression_test.go— the referenced file is gitignored and absent from a clean clone.Test plan
go test ./..., cross-compile matrix)go build ./...andgo vet ./...clean (verified locally before push)