Skip to content

fix: return an error instead of panicking on a truncated build context archive - #58

Open
lbarrosby wants to merge 1 commit into
tsuru:mainfrom
lbarrosby:fix/extract-gzip-read-error
Open

lbarrosby wants to merge 1 commit into
tsuru:mainfrom
lbarrosby:fix/extract-gzip-read-error

Conversation

@lbarrosby

Copy link
Copy Markdown

Why

ExtractGZIPFileToDir (used for the build context sent with a Containerfile deploy) only checks io.EOF from tar.Reader.Next. A truncated or corrupted archive returns another error with a nil header, and h.FileInfo() panics:

panic: runtime error: invalid memory address or nil pointer dereference

It runs inside the errgroup goroutine of generateBuildLocalDir and the gRPC server has no recovery interceptor, so the panic kills the agent and every build running on it.

What

  • Return the read error, same message as ExtractTsuruAppFilesFromAppSourceContext uses.
  • Add pkg/util/gzip_test.go with a round trip test and a truncated archive test (panics on main).

Tested with go test -race ./pkg/util/.

…t archive

ExtractGZIPFileToDir only handled io.EOF from tar.Reader.Next. Any other
error (truncated or corrupted upload) left the header nil and the next
line dereferenced it, panicking inside the errgroup goroutine and taking
the whole agent down with the builds in progress.
@wpjunior

wpjunior commented Nov 6, 2026

Copy link
Copy Markdown
Member

Consider applying #59 to have a automated release process

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