{"record":{"id":"88e184eda3d65902","repo":"BoundaryML/baml","slug":"operation-cancelled-message","errorCode":null,"errorMessage":"Operation cancelled: {message}","messagePattern":"Operation cancelled: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"engine/baml-runtime/src/internal/llm_client/mod.rs","lineNumber":207,"sourceCode":"            }\n            Self::InternalFailure(message) => write!(f, \"Failed before LLM call: {message}\"),\n            Self::Cancelled(message) => write!(f, \"Operation cancelled: {message}\"),\n        }\n    }\n}\n\nimpl LLMResponse {\n    pub fn content(&self) -> Result<&str> {\n        match self {\n            Self::Success(response) => Ok(&response.content),\n            Self::LLMFailure(failure) => Err(anyhow::anyhow!(\"LLM call failed: {failure:?}\")),\n            Self::UserFailure(message) => Err(anyhow::anyhow!(\n                \"Failed before LLM call (user error): {message}\"\n            )),\n            Self::InternalFailure(message) => {\n                Err(anyhow::anyhow!(\"Failed before LLM call: {message}\"))\n            }\n            Self::Cancelled(message) => Err(anyhow::anyhow!(\"Operation cancelled: {message}\")),\n        }\n    }\n}\n\n#[derive(Debug, Clone, Serialize, PartialEq)]\npub struct LLMErrorResponse {\n    pub client: String,\n    pub model: Option<String>,\n    pub prompt: RenderedPrompt,\n    pub request_options: BamlMap<String, serde_json::Value>,\n    #[cfg_attr(target_arch = \"wasm32\", serde(skip_serializing))]\n    pub start_time: web_time::SystemTime,\n    pub latency: web_time::Duration,\n\n    // Short error message\n    pub message: String,\n    pub code: ErrorCode,\n","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/mod.rs#L189-L225","documentation":"BAML's LLMResponse::Cancelled variant is converted to this error when .content() is called on a cancelled LLM call. The runtime raises it when an orchestration attempt was aborted (e.g. due to a cancellation signal or a faster winning strategy) so the response has no content to return.","triggerScenarios":"Calling .content() on an LLMResponse::Cancelled produced by the orchestrator's tokio::select! race branch (call.rs) when a cancel_future wins the select, e.g. client cancellation or an orchestration strategy abandoning a pending attempt.","commonSituations":"Users abort HTTP requests to a BAML-backed service; timeouts cancelling in-flight orchestrations; multi-strategy orchestration where a losing branch is discarded mid-call.","solutions":["Treat this as an expected cancellation, not a bug: catch it and return/propagate the abort to your caller.","Check for cancellation (request abort signal, tokio cancellation token) before starting or while awaiting BAML calls.","If cancellations are unexpected, audit who is dropping/aborting the futures driving the orchestration.","Use retry/orchestration fallback strategies so an aborted attempt falls back to another client."],"exampleFix":"// before\nlet content = llm_response.content()?; // Operation cancelled: ...\n// after\nmatch llm_response {\n    LLMResponse::Cancelled(msg) => Err(MyError::Cancelled(msg)),\n    resp => Ok(resp.content()?),\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_cancelled(resp: &LLMResponse) -> bool {\n    matches!(resp, LLMResponse::Cancelled(_))\n}","tryCatchPattern":"match llm_response {\n    LLMResponse::Cancelled(msg) => return Err(AppError::ClientCancelled(msg)),\n    resp => Ok(resp.content()?),\n}","preventionTips":["Propagate client disconnect/abort signals into your BAML call path so cancellation is handled at the boundary, not inside content().","Avoid holding LLM results past request lifetime; process them before the abort can fire.","Configure orchestration retries/fallbacks so an aborted attempt is retried when appropriate."],"tags":["llm","rust","cancellation","async"],"backgroundTag":"request-timeout","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}