hashicorp/packer · error
transformVersionStream got nil body
Error message
transformVersionStream got nil body
What it means
transformVersionStream converts a GitHub API tag-list response stream into a JSON list of releases; it refuses a nil io.ReadCloser. A nil body means the HTTP response had no body to decode, which the getter treats as an internal/protocol failure rather than silently producing empty versions.
Source
Thrown at packer/plugin-getter/github/getter.go:94
Filename string `json:"filename"`
}{
Checksum: checksumString,
Filename: checksumFilename,
}); err != nil {
return nil, err
}
}
}
_, _ = buffer.WriteString("]")
return io.NopCloser(buffer), nil
}
}
// transformVersionStream get a stream from github tags and transforms it into
// something Packer wants, namely a json list of Release.
func transformVersionStream(in io.ReadCloser) (io.ReadCloser, error) {
if in == nil {
return nil, fmt.Errorf("transformVersionStream got nil body")
}
defer in.Close()
dec := json.NewDecoder(in)
m := []struct {
Ref string `json:"ref"`
}{}
if err := dec.Decode(&m); err != nil {
return nil, err
}
out := []plugingetter.Release{}
for _, m := range m {
out = append(out, plugingetter.Release{
Version: strings.TrimPrefix(m.Ref, "refs/tags/"),
})
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Retry the plugin install; transient HTTP issues may yield empty bodies.
- Check proxy/TLS middleboxes that may strip or truncate GitHub API responses.
- Update Packer — newer releases handle GitHub API changes in the getter.
- Use a protocol:// (file/http) or required_plugins pinning to bypass flaky github discovery.
Defensive patterns
Strategy: retry
Validate before calling
if resp.Body == nil {
return fmt.Errorf("github tags response has no body; status=%d", resp.StatusCode)
} Try / catch
versions, err := getter.Get(...)
if err != nil && strings.Contains(err.Error(), "nil body") {
/* retry once, then fall back to a different source protocol */
} Prevention
- Keep Packer updated so getter changes track GitHub API behavior.
- Avoid proxies/middleboxes that alter or truncate response bodies.
- Pin plugin sources with explicit version constraints to reduce discovery calls.
When it happens
Trigger: Called after fetching the github tags stream; a nil ReadCloser is passed in — e.g. the HTTP client returned a response with nil Body or a code path constructs the request without a body due to a failed/aborted response.
Common situations: Unusual proxy or TLS interception stripping the response body; a mocked/tested HTTP client returning a bare response; an upstream change in how the tags endpoint responds during `packer init` with a github.com source.
Related errors
- Error reading checksum file: %s
- Invalid github.com URI %q: a Github-compatible source must b
- %q doesn't appear to be a valid %q source address; check sou
- malformed filename expected %s{version}_x{protocol-version}_
- wrong version: %s does not match expected %s
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/1f92485bd976313b.
Report an issue: GitHub.