{"record":{"id":"cd32a3baacff9581","repo":"BoundaryML/baml","slug":"message-stream","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs","lineNumber":429,"sourceCode":"                                    message,\n                                    finish_reason: s.metadata.finish_reason.clone(),\n                                }\n                            )))\n                        } else {\n                            Some(parse_fn(&s.content))\n                        }\n                    }\n                    LLMResponse::LLMFailure(LLMErrorResponse {\n                        code,\n                        client,\n                        message,\n                        raw_response,\n                        ..\n                    }) => {\n                        match code {\n                            // This is some internal BAML error, so handle it like any other error\n                            crate::internal::llm_client::ErrorCode::Other(2) => {\n                                Some(Err(anyhow::anyhow!(message.clone())))\n                            }\n                            _ => Some(Err(anyhow::anyhow!(\n                                crate::errors::ExposedError::ClientHttpError {\n                                    client_name: client.clone(),\n                                    message: message.clone(),\n                                    status_code: code.clone(),\n                                    detailed_message: message.clone(),\n                                    raw_response: raw_response.clone(),\n                                }\n                            ))),\n                        }\n                    }\n                    other => {\n                        None\n                    },\n                };\n\n                // parsed_response.map(|r| r.and_then(|v| parsed_value_to_response(v)));","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/orchestrator/stream.rs#L411-L447","documentation":"When a streamed LLM response fails, the orchestrator maps the error code: code Other(2) is treated as an internal BAML error and the raw message is bubbled up directly; any other code becomes a ClientHttpError. The displayed message is the underlying provider failure text.","triggerScenarios":"A stream node returns a Failure with ErrorCode::Other(2) — BAML-internal errors such as prompt-render or client-construction failures surfaced during streaming.","commonSituations":"Internal BAML errors while building the request (bad media, config issues) surfacing mid-orchestration; provider SDK raising non-HTTP errors wrapped as Other(2).","solutions":["Read the inner {message} to identify the actual BAML-internal failure","Check media/file inputs are properly resolved (url/base64) before the call","Validate the client configuration (api keys, model names) in clients.baml","Update BAML if the message suggests an internal invariant failure, and file an issue if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate media inputs are resolved before calling\nfunction mediaReady(m) {\n  return m && (m.base64 != null || m.url != null);\n}","typeGuard":"const isInternalBamlError = (e) => /BAML internal error/i.test(String(e?.message ?? e));","tryCatchPattern":"try {\n  const res = await b.functions.F(input);\n} catch (e) {\n  if (isInternalBamlError(e)) {\n    console.error('BAML internal failure:', String(e));\n    throw new Error('BAML internal error — check media/config, report if reproducible');\n  }\n  throw e;\n}","preventionTips":["Resolve all media to base64/URL before calls","Keep BAML runtime and CLI versions aligned","Validate client config with `baml-cli` test generation","Report reproducible internal errors upstream"],"tags":["internal-error","streaming","orchestration"],"backgroundTag":"api-error-response","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"}