{"record":{"id":"dbe3f479f2994752","repo":"zed-industries/zed","slug":"error-parsing-json-error-n-line-dbe3f4","errorCode":null,"errorMessage":"Error parsing JSON: {error:?}\\n{line:?}","messagePattern":"Error parsing JSON: (.+?)\\\\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/opencode/src/opencode.rs","lineNumber":965,"sourceCode":"        .method(Method::POST)\n        .uri(uri)\n        .header(\"Content-Type\", \"application/json\")\n        .header(\"Authorization\", format!(\"Bearer {api_key}\"))\n        .extra_headers(extra_headers)\n        .body(AsyncBody::from(serde_json::to_string(&request)?))?;\n    let mut response = client.send(request).await?;\n    if response.status().is_success() {\n        let reader = BufReader::new(response.into_body());\n        Ok(reader\n            .lines()\n            .filter_map(|line| async move {\n                match line {\n                    Ok(line) => {\n                        if let Some(line) = line.strip_prefix(\"data: \") {\n                            match serde_json::from_str(line) {\n                                Ok(response) => Some(Ok(response)),\n                                Err(error) => {\n                                    Some(Err(anyhow!(\"Error parsing JSON: {error:?}\\n{line:?}\")))\n                                }\n                            }\n                        } else {\n                            None\n                        }\n                    }\n                    Err(error) => Some(Err(anyhow!(error))),\n                }\n            })\n            .boxed())\n    } else {\n        let mut text = String::new();\n        response.body_mut().read_to_string(&mut text).await?;\n        Err(anyhow!(\n            \"error during streamGenerateContent via OpenCode, status code: {:?}, body: {}\",\n            response.status(),\n            text\n        ))","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/opencode/src/opencode.rs#L947-L983","documentation":"A `data:` line in the SSE stream from stream_generateContent failed to deserialize into the expected response type. The offending line and parse error are included; causes are a schema drift between the server payload and the client structs, or a truncated/interleaved SSE line.","triggerScenarios":"Thrown at crates/opencode/src/opencode.rs:965 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the failing line to determine whether the payload schema changed and update the deserialization structs","If lines are truncated, check for proxy or buffering issues mangling the SSE stream","Retry the request — occasional malformed chunks can be transient"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}