{"record":{"id":"515299993b5d2489","repo":"cloudflare/cloudflared","slug":"api-call-to-s-failed-with-status-d-s","errorCode":null,"errorMessage":"API call to %s failed with status %d: %s","messagePattern":"API call to (.+?) failed with status (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/base_client.go","lineNumber":241,"sourceCode":"\t\tvar errorsResp response\n\t\tif json.NewDecoder(resp.Body).Decode(&errorsResp) == nil {\n\t\t\tif err := errorsResp.checkErrors(); err != nil {\n\t\t\t\treturn errors.Errorf(\"Failed to %s: %s\", op, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch resp.StatusCode {\n\tcase http.StatusOK:\n\t\treturn nil\n\tcase http.StatusBadRequest:\n\t\treturn ErrBadRequest\n\tcase http.StatusUnauthorized, http.StatusForbidden:\n\t\treturn ErrUnauthorized\n\tcase http.StatusNotFound:\n\t\treturn ErrNotFound\n\t}\n\treturn errors.Errorf(\"API call to %s failed with status %d: %s\", op,\n\t\tresp.StatusCode, http.StatusText(resp.StatusCode))\n}\n","sourceCodeStart":223,"sourceCodeEnd":244,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/base_client.go#L223-L244","documentation":"Fallback HTTP failure in RESTClient.statusCodeToError: the API responded with a status that is neither 200 nor one of the mapped sentinel statuses (400/401/403/404) and the body carried no parseable JSON errors. The error names the operation, status code, and its HTTP text (e.g. 429, 500, 502).","triggerScenarios":"Thrown at cfapi/base_client.go:241 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["For 429, back off and retry — rate limited by the Cloudflare API.","For 5xx, retry later; the failure is server-side.","Check the operation name and status in the message before escalating."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}