BoundaryML/baml · error

getattr(StreamState)

Error message

getattr(StreamState)

What it means

pythonize_strict fetches `StreamState` from the partial-types Python module to wrap streaming values. `.expect("getattr(StreamState)")` panics if the module does not expose that attribute, meaning the Python runtime package is missing or renamed the class.

Source

Thrown at engine/language_client_python/src/types/function_results.rs:367

        Ok::<Py<PyAny>, PyErr>(checked_instance.into())
    } else {
        Ok(py_value_without_constraints)
    }?;

    let value_with_possible_completion_state = if completion_state.display && allow_partials {
        let value_type = value_with_possible_checks.bind(py).get_type();

        // Prepare the properties dictionary
        let properties_dict = pyo3::types::PyDict::new(py);
        properties_dict.set_item("value", value_with_possible_checks)?;
        properties_dict.set_item("state", format!("{:?}", completion_state.state))?;

        // Prepare type parameters for StreamingState[...]
        let type_parameters_tuple = PyTuple::new(py, [value_type.as_ref()]).expect("PyTuple::new");

        let class_streaming_state_type_constructor = partial_cls_module
            .getattr("StreamState")
            .expect("getattr(StreamState)");
        let class_completion_state_type: Bound<'_, PyAny> = class_streaming_state_type_constructor
            .call_method1("__class_getitem__", (type_parameters_tuple,))
            .expect("__class_getitem__ for streaming");

        let streaming_state_instance = class_completion_state_type
            .call_method(model_validate_method, (properties_dict.clone(),), None)
            .expect(model_validate_method);

        Ok::<Py<PyAny>, PyErr>(streaming_state_instance.into())
    } else {
        Ok(value_with_possible_checks)
    }?;

    Ok(value_with_possible_completion_state)
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. pip install --upgrade baml to match the engine version
  2. Check the installed baml_py version with pip show baml-py and align with the BAML CLI version
  3. Reinstall the virtualenv to fix partial installs
  4. File a bug if versions match
Defensive patterns

Strategy: validation

Validate before calling

python -c "import baml_py, inspect; print([n for n in dir(baml_py) if 'Stream' in n])"  # must include StreamState

Prevention

When it happens

Trigger: Any streaming call (allow_partials=true) where partial_cls_module lacks a `StreamState` attribute — e.g. an older baml-py installed against a newer engine.

Common situations: Version skew: engine emits streaming state metadata but the installed Python client predates the StreamState class, or a broken/partial pip install.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/8eb73a4def097d78. Report an issue: GitHub.