{"record":{"id":"f795577f03a765ed","repo":"BoundaryML/baml","slug":"no-events-in-the-chain","errorCode":null,"errorMessage":"No events in the chain","messagePattern":"No events in the chain","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/types/response.rs","lineNumber":82,"sourceCode":"    pub(crate) fn event_chain(\n        &self,\n    ) -> &Vec<(\n        OrchestrationScope,\n        LLMResponse,\n        Option<Result<ResponseBamlValue>>,\n    )> {\n        &self.event_chain\n    }\n\n    pub fn new_chain(\n        chain: Vec<(\n            OrchestrationScope,\n            LLMResponse,\n            Option<Result<ResponseBamlValue>>,\n        )>,\n    ) -> Result<Self> {\n        if chain.is_empty() {\n            anyhow::bail!(\"No events in the chain\");\n        }\n\n        Ok(Self { event_chain: chain })\n    }\n\n    pub fn content(&self) -> Result<&str> {\n        self.llm_response().content()\n    }\n\n    pub fn llm_response(&self) -> &LLMResponse {\n        &self.event_chain.last().unwrap().1\n    }\n\n    pub fn scope(&self) -> &OrchestrationScope {\n        &self.event_chain.last().unwrap().0\n    }\n\n    pub fn parsed(&self) -> &Option<Result<ResponseBamlValue>> {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/types/response.rs#L64-L100","documentation":"ResponseChain::new_chain validates that the orchestration event chain passed to it contains at least one event; an empty Vec is rejected because a chain with no events cannot produce content, timing, or usage information. This is an input-validation guard on a public constructor.","triggerScenarios":"Calling ResponseChain::new_chain(vec![]) or equivalent with an empty list of (scope, llm_response, result) tuples, e.g. when orchestration produced no LLM calls at all before building the response chain.","commonSituations":"Retry/orchestration logic that filters out all failed attempts and then builds a chain from the (now empty) surviving list; streams where no LLM call was ever dispatched; custom orchestration code bypassing the normal runner.","solutions":["Check that the events/chain vector is non-empty before calling new_chain, and return a more meaningful error upstream if it is.","Fix the orchestration logic so at least one LLM response (success or failure) is always recorded.","If a chain can legitimately be empty in your flow, handle that case before constructing a ResponseChain."],"exampleFix":"// before\nlet chain = ResponseChain::new_chain(events)?; // events may be empty\n\n// after\nif events.is_empty() {\n    anyhow::bail!(\"Orchestration produced no LLM events\");\n}\nlet chain = ResponseChain::new_chain(events)?;","handlingStrategy":"validation","validationCode":"if events.is_empty() {\n    anyhow::bail!(\"no LLM events recorded; cannot build response chain\");\n}\nlet chain = ResponseChain::new_chain(events)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the events vector length before calling new_chain","Ensure orchestration always records at least one LLM response","Return a domain-specific error instead of leaking the internal message"],"tags":["rust","validation","orchestration"],"backgroundTag":"empty-required-field","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}