BoundaryML/baml · error
text is required
Error message
text is required
What it means
FFI argument validation for the parse entry point: the kwargs map carried no 'text' entry. The parse function's entire input is the text to parse, so a missing key (empty or malformed argument buffer) is rejected before any parsing runs. A present-but-non-string 'text' is a sibling error ('text is not a string').
Source
Thrown at engine/language_client_cffi/src/ffi/functions.rs:173
let BamlFunctionArguments {
kwargs,
client_registry,
env_vars,
collectors: _,
type_builder,
tags: _,
} = BamlFunctionArguments::from_c_buffer(encoded_args, length)?;
let ctx = runtime.create_ctx_manager(BamlValue::String("cffi".to_string()), None);
let text = match kwargs.get("text") {
Some(t) => match t.as_str() {
Some(s) => s.to_string(),
None => {
return Err(anyhow::anyhow!("text is not a string"));
}
},
None => {
return Err(anyhow::anyhow!("text is required"));
}
};
let allow_stream_types = match kwargs.get("stream") {
Some(s) => match s.as_bool() {
Some(b) => b,
None => {
return Err(anyhow::anyhow!("stream is not a boolean"));
}
},
None => false,
};
// Spawn an async task to await the future and call the callback when done.
// Ensure that a Tokio runtime is running in your application.
let rt = RUNTIME.clone();
rt.spawn(async move {
let result = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| async {
// TODO: There's a race condition bug here. Technically we should COPY the type builder, not just clone it.View on GitHub (pinned to bd85ce9dee)
Solutions
- Pass a "text" keyword argument with the string to parse
- Check for typos in the argument name (exact lowercase "text")
- If using a wrapper, ensure it forwards the text argument to the FFI call
Example fix
// before
baml.baml_call_function_parse(rt, "ExtractResume") # no kwargs
// after
baml.baml_call_function_parse(rt, "ExtractResume", {"text": llm_output}) Defensive patterns
Strategy: validation
Validate before calling
if "text" not in kwargs or kwargs["text"] is None:
raise ValueError("parse call requires a 'text' kwarg") Type guard
def has_text(kwargs): return isinstance(kwargs.get('text'), str) Try / catch
try:
parsed = baml.baml_call_function_parse(rt, fn, kwargs)
except Exception as e:
if 'text is required' in str(e):
raise ValueError("Provide {'text': <llm output string>} to parse")
raise Prevention
- Always include the 'text' kwarg (exact spelling) in parse calls
- Centralize parse invocations in one helper that validates kwargs
- Don't let generic wrappers silently drop unknown kwargs
When it happens
Trigger: Invoking the parse FFI entry point without including the "text" key in the kwargs map, e.g. misspelling it as txt or Text.
Common situations: Argument name typos, refactors that renamed the variable but not the kwarg key, or calling parse through a generic wrapper that drops unknown kwargs.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- text is not a string
- colored diagnostics have a source highlighter
- Engine not initialized. Call create_baml_runtime first.
- Project not initialized
- unsupported handle type
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/dbb0b6817078d638.
Report an issue: GitHub.