{"record":{"id":"a8f4b7ce5e673c6f","repo":"hashicorp/packer","slug":"failed-to-fetch-release-index-w","errorCode":null,"errorMessage":"failed to fetch release index: %w","messagePattern":"failed to fetch release index: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/packer_release_fetch.go","lineNumber":65,"sourceCode":"\tArch     string `json:\"arch\"`\n\tFilename string `json:\"filename\"`\n\tURL      string `json:\"url\"`\n}\n\n// fetchLatestPackerVersion queries the HashiCorp releases index, sorts all\n// stable (non-prerelease) versions with semver, and returns the highest one.\nfunc fetchLatestPackerVersion(ctx context.Context, client *http.Client) (string, error) {\n\tindexURL := getReleaseBaseURL() + \"/packer/index.json\"\n\tvar indexData releaseIndex\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, indexURL, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to build index request: %w\", err)\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to fetch release index: %w\", err)\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"HTTP %d for %s\", resp.StatusCode, indexURL)\n\t}\n\n\terr = json.NewDecoder(resp.Body).Decode(&indexData)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to retrieve packer release index from %s: %w\", indexURL, err)\n\t}\n\n\tvar semverList []*semver.Version\n\tfor vStr := range indexData.Versions {\n\t\tv, parseErr := semver.NewVersion(vStr)\n\t\tif parseErr != nil {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/packer_release_fetch.go#L47-L83","documentation":"The HTTP GET to the Packer releases index endpoint failed at the transport layer: `client.Do(req)` returned an error before any HTTP response was produced. This wraps the underlying net/http error (DNS failure, TCP connect error, TLS handshake failure, or the request context being canceled/timed out).","triggerScenarios":"fetchLatestPackerVersion calls client.Do on the index request; the error fires when there is no network connectivity to releases.hashicorp.com, DNS resolution fails, a proxy/firewall blocks the connection, TLS fails, or ctx is canceled/deadline exceeded mid-request.","commonSituations":"CI runner or air-gapped machine without internet egress; corporate proxy required but unset (HTTP(S)_PROXY); transient DNS outage; releases.hashicorp.com incident; build context deadline canceled before the request finished.","solutions":["Read the wrapped error to distinguish DNS/connect/TLS/timeout and confirm network egress to https://releases.hashicorp.com/packer/index.json.","Configure proxy settings (HTTPS_PROXY) if the environment requires a proxy for outbound HTTPS.","Retry the build — transient network/DNS blips commonly cause this; the caller may already wrap this in packer's retry helper.","Check status.hashicorp.com for an ongoing releases endpoint outage.","Ensure the context passed into the provisioner has an adequate deadline."],"exampleFix":"// before: blocked by corporate proxy, no egress\nexport HTTPS_PROXY=http://proxy.corp.example:3128\n// after: request succeeds via configured proxy","handlingStrategy":"retry","validationCode":"// Pre-flight connectivity check\nreq, _ := http.NewRequestWithContext(ctx, http.MethodHead, \"https://releases.hashicorp.com/packer/index.json\", nil)\nresp, err := client.Do(req)\nif err != nil {\n\treturn fmt.Errorf(\"no egress to releases.hashicorp.com: %w\", err)\n}\nresp.Body.Close()","typeGuard":"func isNetworkError(err error) bool {\n\tvar ne net.Error\n\treturn err != nil && (errors.As(err, &ne) || errors.Is(err, context.DeadlineExceeded) || errors.Is(err, syscall.ECONNREFUSED))\n}","tryCatchPattern":"var latest string\nerr := retry.Config{Tries: 3, ShouldRetry: func(err error) bool { return isNetworkError(err) }}.Run(ctx, func(ctx context.Context) error {\n\tvar e error\n\tlatest, e = fetchLatestPackerVersion(ctx, client)\n\treturn e\n})","preventionTips":["Ensure build environments (CI runners, containers) have outbound HTTPS egress.","Set HTTPS_PROXY in proxied networks.","Give the provisioner context a generous deadline.","Use packer-plugin-sdk/retry for transient network faults.","Monitor DNS health in your build network."],"tags":["network","http","dns","connectivity"],"backgroundTag":"http-request-failed","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"}