{"record":{"id":"3a9e564ab4cdf583","repo":"BoundaryML/baml","slug":"stream-is-not-a-boolean","errorCode":null,"errorMessage":"stream is not a boolean","messagePattern":"stream is not a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/language_client_cffi/src/ffi/functions.rs","lineNumber":180,"sourceCode":"    } = BamlFunctionArguments::from_c_buffer(encoded_args, length)?;\n\n    let ctx = runtime.create_ctx_manager(BamlValue::String(\"cffi\".to_string()), None);\n    let text = match kwargs.get(\"text\") {\n        Some(t) => match t.as_str() {\n            Some(s) => s.to_string(),\n            None => {\n                return Err(anyhow::anyhow!(\"text is not a string\"));\n            }\n        },\n        None => {\n            return Err(anyhow::anyhow!(\"text is required\"));\n        }\n    };\n    let allow_stream_types = match kwargs.get(\"stream\") {\n        Some(s) => match s.as_bool() {\n            Some(b) => b,\n            None => {\n                return Err(anyhow::anyhow!(\"stream is not a boolean\"));\n            }\n        },\n        None => false,\n    };\n\n    // Spawn an async task to await the future and call the callback when done.\n    // Ensure that a Tokio runtime is running in your application.\n    let rt = RUNTIME.clone();\n    rt.spawn(async move {\n        let result = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| async {\n            // TODO: There's a race condition bug here. Technically we should COPY the type builder, not just clone it.\n            let type_builder = type_builder.map(|t| t.type_builder.as_ref().clone());\n            runtime.parse_llm_response(\n                func_name,\n                text,\n                allow_stream_types,\n                &ctx,\n                type_builder.as_ref(),","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_cffi/src/ffi/functions.rs#L162-L198","documentation":"The optional \"stream\" kwarg in call_function_parse_from_c must be a boolean BAML value when provided; it controls whether streaming result types are allowed. Passing a non-boolean value (string \"true\", int 1, etc.) triggers this error instead of a silent coercion.","triggerScenarios":"Calling baml_call_function_parse with kwargs[\"stream\"] set to a non-boolean BamlValue (string, number, null-object).","commonSituations":"Passing Python truthy values like \"true\"/1 instead of True, JSON configs where booleans arrived as strings, or building kwargs dynamically from untyped user config.","solutions":["Pass stream as a real boolean (true/false) not a string or number","If the value comes from config, cast it: bool(str_value == 'true') for strings","Omit the stream kwarg entirely to use the default (False)"],"exampleFix":"// before\nbaml.baml_call_function_parse(rt, \"fn\", {\"text\": t, \"stream\": \"true\"})\n// after\nbaml.baml_call_function_parse(rt, \"fn\", {\"text\": t, \"stream\": True})","handlingStrategy":"type-guard","validationCode":"if \"stream\" in kwargs and not isinstance(kwargs[\"stream\"], bool):\n    raise TypeError(\"stream must be a bool\")","typeGuard":"def is_bool(v): return isinstance(v, bool)","tryCatchPattern":"try:\n    parsed = baml.baml_call_function_parse(rt, fn, kwargs)\nexcept Exception as e:\n    if 'stream is not a boolean' in str(e):\n        kwargs['stream'] = kwargs['stream'] in (True, 'true', 1)\n        parsed = baml.baml_call_function_parse(rt, fn, kwargs)\n    else:\n        raise","preventionTips":["Pass real booleans, not 'true'/1 strings from JSON config","Omit stream to accept the default false","Normalize config values to bool before building kwargs"],"tags":["ffi","rust","type-mismatch","boolean"],"backgroundTag":"type-mismatch","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"}