{"record":{"id":"dc8648224197259d","repo":"zed-industries/zed","slug":"anyhow-error-failed-to-parse-openai-response-i","errorCode":null,"errorMessage":"anyhow!(error) — failed to parse OpenAI response into ResponseStreamResult (message from parse error)","messagePattern":"anyhow!\\(error\\) — failed to parse OpenAI response into ResponseStreamResult \\(message from parse error\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/open_ai/src/open_ai.rs","lineNumber":1135,"sourceCode":"                        Some(Err(anyhow!(\n                            language_model_core::LanguageModelCompletionError::from_provider_response(\n                                provider_name,\n                                None,\n                                error.code.or(error.error_type),\n                                error.message,\n                                None,\n                                category,\n                            )\n                        )))\n                    }\n                    Err(error) => {\n                        log::error!(\n                            \"Failed to parse OpenAI response into ResponseStreamResult: `{}`\\n\\\n                            Response: `{}`\",\n                            error,\n                            value,\n                        );\n                        Some(Err(anyhow!(error)))\n                    }\n                }\n            }\n        })\n        .boxed())\n}\n\nfn chat_completion_request<RequestBody>(\n    provider_name: &str,\n    api_url: &str,\n    api_key: &str,\n    extra_headers: &CustomHeaders,\n    request: &RequestBody,\n) -> std::result::Result<HttpRequest<AsyncBody>, RequestError>\nwhere\n    RequestBody: Serialize + ?Sized,\n{\n    let body = serde_json::to_string(request).map_err(|error| RequestError::SerializeRequest {","sourceCodeStart":1117,"sourceCodeEnd":1153,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/open_ai/src/open_ai.rs#L1117-L1153","documentation":"Parse-error branch of the OpenAI stream handler: an incoming SSE data chunk failed to deserialize into ResponseStreamResult (the union of successful deltas and error payloads). The serde error is logged and wrapped in anyhow! so it surfaces as an error completion event; the fault is malformed or unexpected JSON from the OpenAI-compatible endpoint that does not match the expected response schema.","triggerScenarios":"Thrown at crates/open_ai/src/open_ai.rs:1135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the logged serde message to see which field failed to deserialize and compare it with the endpoint's actual response schema","Confirm the base URL targets an OpenAI-compatible API whose streaming chunk format matches the one Zed expects","Upgrade or adjust the provider integration if the endpoint emits non-standard fields in streamed chunks"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-09-05T10:33:00.413Z","contentChangedAt":"2026-09-05T10:33:00.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}