{"record":{"id":"cf856126ce30dacd","repo":"plandex-ai/plandex","slug":"error-reading-error-response-w","errorCode":null,"errorMessage":"error reading error response: %w","messagePattern":"error reading error response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/client.go","lineNumber":370,"sourceCode":"\t\treq.Header.Set(\"Authorization\", \"Bearer \"+client.ApiKey)\n\t}\n\tif client.OpenAIOrgId != \"\" {\n\t\treq.Header.Set(\"OpenAI-Organization\", client.OpenAIOrgId)\n\t}\n\n\taddOpenRouterHeaders(req)\n\n\t// Send the request\n\tresp, err := httpClient.Do(req) //nolint:bodyclose // body is closed in stream.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error making request: %w\", err)\n\t}\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\tdefer resp.Body.Close()\n\t\tbody, err := io.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading error response: %w\", err)\n\t\t}\n\t\treturn nil, &HTTPError{\n\t\t\tStatusCode: resp.StatusCode,\n\t\t\tBody:       string(body),\n\t\t\tHeader:     resp.Header.Clone(), // retain Retry-After etc.\n\t\t}\n\t}\n\n\t// Log response headers\n\t// log.Println(\"Response headers:\")\n\t// for key, values := range resp.Header {\n\t// \tlog.Printf(\"%s: %v\\n\", key, values)\n\t// }\n\n\treader := &StreamReader[types.ExtendedChatCompletionStreamResponse]{\n\t\treader:             bufio.NewReader(resp.Body),\n\t\tresponse:           resp,\n\t\temptyMessagesLimit: 30,","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/client.go#L352-L388","documentation":"The provider returned an HTTP error status, and reading that error response body with io.ReadAll also failed. The original API error is lost because the body could not be drained (connection reset mid-body).","triggerScenarios":"Thrown at app/server/model/client.go:370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request to get a fresh response","Check provider status/health if errors persist","Log the status code alongside to diagnose the original API error"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}