{"record":{"id":"56f100b95647a261","repo":"BoundaryML/baml","slug":"s","errorCode":null,"errorMessage":"{s:?}","messagePattern":"\\{s:\\?\\}","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/mod.rs","lineNumber":58,"sourceCode":"        baml_value.clone().into();\n    let meta_field_type: BamlValueWithMeta<TypeIR> = baml_value.clone().into();\n\n    let value_with_response_checks: BamlValueWithMeta<Vec<ResponseCheck>> = baml_value_with_meta\n        .map_meta(|cs| {\n            cs.iter()\n                .map(|(label, expr, result)| {\n                    let status = (if *result { \"succeeded\" } else { \"failed\" }).to_string();\n                    ResponseCheck {\n                        name: label.clone(),\n                        expression: expr.0.clone(),\n                        status,\n                    }\n                })\n                .collect()\n        });\n\n    let baml_value_with_streaming =\n        validate_streaming_state(ir, &baml_value, mode).map_err(|s| anyhow::anyhow!(\"{s:?}\"))?;\n\n    // Combine the baml_value, its types, the parser flags, and the streaming state\n    // into a final value.\n    // Node that we set the StreamState to `None` unless `allow_partials`.\n    let response_value = baml_value_with_streaming\n        .zip_meta(&value_with_response_checks)?\n        .zip_meta(&meta_flags)?\n        .zip_meta(&meta_field_type)?\n        .map_meta(|(((x, y), z), ft)| {\n            jsonish::ResponseValueMeta(z.clone(), y.clone(), x.clone(), ft.clone())\n        });\n    Ok(ResponseBamlValue(response_value))\n}\n\n// Whether we should download a url into a base64 (resolving it if necessary), as well as\n// whether we should add the mime type, etc.\n#[derive(Clone, Copy, PartialEq)]\npub enum ResolveMediaUrls {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/mod.rs#L40-L76","documentation":"During streaming response assembly, parsed_value_to_response runs validate_streaming_state to confirm the partially streamed value is consistent with the function's IR and streaming mode. When validation fails, the returned error is a debug-formatted (:) list of streaming-state problem strings, wrapped with anyhow. It indicates the streamed partial output cannot be reconciled into a valid partial BAML value.","triggerScenarios":"Calling to_response / parsed_value_to_response (e.g. via stable_keys2) on a streamed BAML value where mode allows partials but the partial state is invalid — e.g. required fields missing in an in-progress object that cannot legally be partial, malformed enum/class matches mid-stream, or mismatches between the parsed value shape and the IR's expected output type.","commonSituations":"Custom streaming parsers or partially consumed stream chunks fed back into the runtime; output schema changes without regenerating the client so the streamed shape no longer matches the IR; feeding truncated LLM output into partial parsing with allow_partials enabled.","solutions":["Read the debug-formatted list in the message — it enumerates each invalid streaming-state entry","Regenerate the BAML client so IR and parser agree on the output schema","Ensure the stream chunk passed to the parser is complete/consistent (not arbitrarily truncated mid-token in a way the parser rejects)","If partials are not needed, disable allow_partials so incomplete values are not validated as partials"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Check stream shape/schema agreement before parsing partials\nif output_schema_changed {\n    regen_client(); // ensure IR matches streamed value types\n}","typeGuard":null,"tryCatchPattern":"match validate_stream_result(raw_stream) {\n    Ok(v) => v,\n    Err(e) => {\n        // message contains a debug list of invalid streaming states\n        log::warn!(\"streaming state invalid: {e}\");\n        fall_back_to_non_streaming_call()\n    }\n}","preventionTips":["Regenerate the BAML client whenever the output schema changes","Only feed complete, parser-consistent chunks into partial streaming","Disable allow_partials if you don't need partial values","Pin BAML runtime/CLI versions so IR and parser agree"],"tags":["baml","streaming","partial-parsing","schema-mismatch"],"backgroundTag":"unexpected-response-shape","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}