{"record":{"id":"fbcf8b462c3e4d26","repo":"JuliusBrussee/caveman","slug":"rewriter-s-status-d-s","errorCode":null,"errorMessage":"rewriter: %s: status %d: %s","messagePattern":"rewriter: (.+?): status (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rewriter/provider.go","lineNumber":202,"sourceCode":"\t}\n\n\tresp, err := c.doer(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: %w\", endpoint, err)\n\t}\n\t// An injected doer is caller code; a nil response or body must surface as an\n\t// error rather than a panic inside the proxy hot path.\n\tif resp == nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: nil response\", endpoint)\n\t}\n\tif resp.Body == nil {\n\t\tresp.Body = http.NoBody\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < 200 || resp.StatusCode > 299 {\n\t\tdetail, _ := io.ReadAll(io.LimitReader(resp.Body, maxErrorBody))\n\t\treturn nil, fmt.Errorf(\"rewriter: %s: status %d: %s\", endpoint, resp.StatusCode, strings.TrimSpace(string(detail)))\n\t}\n\traw, err := io.ReadAll(io.LimitReader(resp.Body, maxProviderResponseBody+1))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"rewriter: read response: %w\", err)\n\t}\n\tif len(raw) > maxProviderResponseBody {\n\t\treturn nil, fmt.Errorf(\"rewriter: response exceeds %d bytes\", maxProviderResponseBody)\n\t}\n\treturn raw, nil\n}\n","sourceCodeStart":184,"sourceCodeEnd":213,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/rewriter/provider.go#L184-L213","documentation":"The rewriter provider returned a non-2xx HTTP status. The body is read (bounded by maxErrorBody) and included so the caller can see the provider's error detail; common causes are invalid API key, rate limiting, or a bad model name at the rewriter provider.","triggerScenarios":"Thrown at rewriter/provider.go:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the status and body detail: fix credentials for 401/403, retry after backoff on 429/5xx","Rate-limit or disable the rewriter if the provider keeps rejecting requests"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}