{"record":{"id":"bc7fc7da4033a90f","repo":"zed-industries/zed","slug":"response-contained-no-choices","errorCode":null,"errorMessage":"Response contained no choices","messagePattern":"Response contained no choices","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/copilot_chat/src/model.rs","lineNumber":362,"sourceCode":"    struct State {\n        events: Pin<Box<dyn Send + Stream<Item = Result<ResponseEvent>>>>,\n        tool_calls_by_index: HashMap<usize, RawToolCall>,\n        reasoning_opaque: Option<String>,\n        reasoning_text: Option<String>,\n    }\n\n    futures::stream::unfold(\n        State {\n            events,\n            tool_calls_by_index: HashMap::default(),\n            reasoning_opaque: None,\n            reasoning_text: None,\n        },\n        move |mut state| async move {\n            if let Some(event) = state.events.next().await {\n                match event {\n                    Ok(event) => {\n                        let Some(choice) = event.choices.first() else {\n                            return Some((\n                                vec![Err(anyhow!(\"Response contained no choices\").into())],\n                                state,\n                            ));\n                        };\n\n                        let delta = if is_streaming {\n                            choice.delta.as_ref()\n                        } else {\n                            choice.message.as_ref()\n                        };\n\n                        let Some(delta) = delta else {\n                            return Some((\n                                vec![Err(anyhow!(\"Response contained no delta\").into())],\n                                state,\n                            ));\n                        };","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/copilot_chat/src/model.rs#L344-L380","documentation":"While mapping Copilot Chat streaming events to language-model completion events, a chunk arrived whose choices list was empty; the parser requires at least one choice per event and treats an empty list as a malformed response.","triggerScenarios":"Thrown at crates/copilot_chat/src/model.rs:346 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as a transient protocol quirk and retry the completion","Update Zed if the Copilot Chat event format changed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}