{"record":{"id":"fcbf7f43e1e92aec","repo":"hashicorp/terraform","slug":"r-status","errorCode":null,"errorMessage":"{r.Status}","messagePattern":"\\{r\\.Status\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_common.go","lineNumber":758,"sourceCode":"\tcase 404:\n\t\treturn tfe.ErrResourceNotFound\n\t}\n\n\terrs, err = decodeErrorPayload(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn errors.New(strings.Join(errs, \"\\n\"))\n}\n\nfunc decodeErrorPayload(r *http.Response) ([]string, error) {\n\t// Decode the error payload.\n\tvar errs []string\n\terrPayload := &jsonapi.ErrorsPayload{}\n\terr := json.NewDecoder(r.Body).Decode(errPayload)\n\tif err != nil || len(errPayload.Errors) == 0 {\n\t\treturn errs, errors.New(r.Status)\n\t}\n\n\t// Parse and format the errors.\n\tfor _, e := range errPayload.Errors {\n\t\tif e.Detail == \"\" {\n\t\t\terrs = append(errs, e.Title)\n\t\t} else {\n\t\t\terrs = append(errs, fmt.Sprintf(\"%s\\n\\n%s\", e.Title, e.Detail))\n\t\t}\n\t}\n\n\treturn errs, nil\n}\n\nfunc isValidAppName(name string) bool {\n\treturn name == \"HCP Terraform\" || name == \"Terraform Enterprise\"\n}\n","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_common.go#L740-L776","documentation":"Fallback error from decodeErrorPayload() when the response body cannot be JSON-decoded or the decoded JSON:API payload has no errors array. In that case the raw HTTP status line (e.g. '500 Internal Server Error') is returned as the error so the caller still sees something meaningful.","triggerScenarios":"An HCP/TFE API response with a non-2xx status whose body is empty, HTML (proxy error page), or malformed JSON — e.g. a corporate proxy returning its own error page, or a gateway timeout.","commonSituations":"Misconfigured egress proxy returning HTML; upstream gateway/CDN error; truncated response; non-JSON error from a middleware layer.","solutions":["Inspect the HTTP status code embedded in the message to classify the failure.","Verify the request is reaching HCP/TFE and not being intercepted by a proxy returning HTML.","Retry transient 5xx gateway errors; report persistent ones with the status code to platform admins.","Check TF_LOG=TRACE output to see the full response body that failed to decode."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := b.readRedactedPlan(ctx, u, token, planID); err != nil {\n    // err.Error() is the raw HTTP status line, e.g. \"502 Bad Gateway\".\n    if strings.Contains(err.Error(), \"5\") || strings.Contains(err.Error(), \"Gateway\") {\n        // likely transient proxy/gateway error — retry with backoff\n    }\n    return err\n}","preventionTips":["Inspect TF_LOG=TRACE to see the raw (often non-JSON) response body.","Verify no intercepting proxy returns HTML error pages.","Retry transient gateway/CDN errors; escalate persistent ones with the status code."],"tags":["terraform","cloud-backend","hcp","tfe","api","http","proxy"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}