{"record":{"id":"1f92485bd976313b","repo":"hashicorp/packer","slug":"transformversionstream-got-nil-body","errorCode":null,"errorMessage":"transformVersionStream got nil body","messagePattern":"transformVersionStream got nil body","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/plugin-getter/github/getter.go","lineNumber":94,"sourceCode":"\t\t\t\t\tFilename string `json:\"filename\"`\n\t\t\t\t}{\n\t\t\t\t\tChecksum: checksumString,\n\t\t\t\t\tFilename: checksumFilename,\n\t\t\t\t}); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_, _ = buffer.WriteString(\"]\")\n\t\treturn io.NopCloser(buffer), nil\n\t}\n}\n\n// transformVersionStream get a stream from github tags and transforms it into\n// something Packer wants, namely a json list of Release.\nfunc transformVersionStream(in io.ReadCloser) (io.ReadCloser, error) {\n\tif in == nil {\n\t\treturn nil, fmt.Errorf(\"transformVersionStream got nil body\")\n\t}\n\tdefer in.Close()\n\tdec := json.NewDecoder(in)\n\n\tm := []struct {\n\t\tRef string `json:\"ref\"`\n\t}{}\n\tif err := dec.Decode(&m); err != nil {\n\t\treturn nil, err\n\t}\n\n\tout := []plugingetter.Release{}\n\tfor _, m := range m {\n\t\tout = append(out, plugingetter.Release{\n\t\t\tVersion: strings.TrimPrefix(m.Ref, \"refs/tags/\"),\n\t\t})\n\t}\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/plugin-getter/github/getter.go#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if resp.Body == nil {\n    return fmt.Errorf(\"github tags response has no body; status=%d\", resp.StatusCode)\n}","typeGuard":null,"tryCatchPattern":"versions, err := getter.Get(...)\nif err != nil && strings.Contains(err.Error(), \"nil body\") {\n    /* retry once, then fall back to a different source protocol */\n}","preventionTips":["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."],"tags":["github","http","plugin-install"],"backgroundTag":"empty-http-response-body","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}