{"record":{"id":"16229f4114483908","repo":"hashicorp/terraform","slug":"resp-status-16229f","errorCode":null,"errorMessage":"resp.Status","messagePattern":"resp\\.Status","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/registry_client.go","lineNumber":130,"sourceCode":"\tc.addHeadersToRequest(req.Request)\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, nil, c.errQueryFailed(addr, err)\n\t}\n\tdefer resp.Body.Close()\n\n\tswitch resp.StatusCode {\n\tcase http.StatusOK:\n\t\t// Great!\n\tcase http.StatusNotFound:\n\t\treturn nil, nil, ErrRegistryProviderNotKnown{\n\t\t\tProvider: addr,\n\t\t}\n\tcase http.StatusUnauthorized, http.StatusForbidden:\n\t\treturn nil, nil, c.errUnauthorized(addr.Hostname)\n\tdefault:\n\t\treturn nil, nil, c.errQueryFailed(addr, errors.New(resp.Status))\n\t}\n\n\t// We ignore the platforms portion of the response body, because the\n\t// installer verifies the platform compatibility after pulling a provider\n\t// versions' metadata.\n\ttype ResponseBody struct {\n\t\tVersions []struct {\n\t\t\tVersion   string   `json:\"version\"`\n\t\t\tProtocols []string `json:\"protocols\"`\n\t\t} `json:\"versions\"`\n\t\tWarnings []string `json:\"warnings\"`\n\t}\n\tvar body ResponseBody\n\n\tdec := json.NewDecoder(resp.Body)\n\tif err := dec.Decode(&body); err != nil {\n\t\treturn nil, nil, c.errQueryFailed(addr, err)\n\t}","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/getproviders/registry_client.go#L112-L148","documentation":"Emitted from registryClient.ProviderVersions(), the GET /v1/providers/{ns}/{type}/versions call. It is the default branch of the status switch: any response code other than 200/404/401/403 (for example 5xx or 429) is wrapped as errQueryFailed(errors.New(resp.Status)).","triggerScenarios":"`terraform init` resolving available provider versions when the registry returns a server error, gateway timeout, or rate-limit response to the version-listing endpoint.","commonSituations":"Registry outage during init; aggressive CI parallelism triggering 429; private/Terraform Enterprise registry returning an unexpected code; flaky corporate proxy.","solutions":["Retry the init; 5xx/429 are typically transient.","Pin exact provider versions in .terraform.lock.hcl / required_providers to reduce version-list lookups.","Use a filesystem or network mirror via provider_installation config.","Check registry status and proxy egress; add retryablehttp backoff if a custom client is in play."],"exampleFix":"# pin versions to minimize registry round-trips and use a mirror\n# ~/.terraformrc\nprovider_installation {\n  filesystem_mirror { path = \"~/.terraform.d/plugin-cache\" }\n}\n# versions.tf\nterraform { required_providers { aws = { source = \"hashicorp/aws\", version = \"5.40.0\" } } }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"# retry init in CI to absorb transient 5xx/429 from the versions endpoint\n#   n=0; until terraform init -input=false || [ $n -ge 4 ]; do n=$((n+1)); sleep $((n*20)); done","preventionTips":["Maintain a warm provider_installation filesystem mirror.","Commit the dependency lock file so version resolution is deterministic and minimal.","Use retryablehttp backoff if you call the registry client directly.","Reduce parallel CI workers hitting the registry simultaneously."],"tags":["network","registry","http","provider-installation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}