Skip to content

fix(image): dead code, FormatBytes safety, and Truncated for daemon extraction - #104

Merged
deveshctl merged 1 commit into
mainfrom
fix/dead-code-and-format-correctness
Oct 2, 2026
Merged

deveshctl merged 1 commit into
mainfrom
fix/dead-code-and-format-correctness

Conversation

@deveshctl

Copy link
Copy Markdown
Owner

Summary

  • ErrNoEngineFound.Cause / Unwrap() removed — the field was never set at either construction site, so Unwrap() always returned nil. Callers match on the type directly; removing the dead field makes the interface honest.
  • FormatBytes negative-input guard — the uint64 cast silently wrapped negative int64 values to large positive values. Now returns a sign-prefixed string for negative inputs, consistent with FormatSignedBytes.
  • Truncated flag fixed for daemon extraction — readFirstFileFromTar truncated the stream to MaxViewSize before returning, so processContent always saw len(data) <= MaxViewSize and never set fc.Truncated. The function now returns the declared tar header size; the caller passes the larger of the stat size and the header size to processContent so the truncation notice is shown correctly for files > 1 MB.
  • Dead internal-docs comment removed from compare_regression_test.go — the referenced file is gitignored and absent from a clean clone.

Test plan

  • CI passes (go test ./..., cross-compile matrix)
  • go build ./... and go vet ./... clean (verified locally before push)

…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.
@deveshctl
deveshctl merged commit 374c946 into main Oct 2, 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.

1 participant