BoundaryML/baml · error · BridgeError
Project not initialized
Error message
Project not initialized
What it means
BridgeError::ProjectNotInitialized indicates the BAML engine exists but no BAML project (function/enum/class definitions compiled from .baml sources) has been loaded into it, so the requested operation has nothing to work against. The bridge distinguishes this from NotInitialized: the runtime handle is present, but the project-level context is missing. Like the other setup variants, it maps to a GenericSdkError on the host side.
Source
Thrown at baml_language/crates/bridge_cffi/src/error.rs:13
//! Error types for bridge_cffi.
use thiserror::Error;
/// Errors that can occur during bridge operations.
#[derive(Debug, Error)]
pub enum BridgeError {
#[error(transparent)]
Ctypes(#[from] bridge_ctypes::CtypesError),
#[error("Engine not initialized. Call create_baml_runtime first.")]
NotInitialized,
#[error("Project not initialized")]
ProjectNotInitialized,
#[error("Engine lock poisoned")]
LockPoisoned,
#[error("{0}")]
Runtime(#[from] bex_project::RuntimeError),
#[error("CallFunctionArgs.call_target must be set")]
MissingCallTarget,
#[error("type arguments are not supported when invoking a BAML function handle")]
FunctionHandleTypeArgs,
#[error("Function not found: {name}")]
FunctionNotFound { name: String },
#[error("Missing argument '{parameter}' for function '{function}'")]View on GitHub (pinned to bd85ce9dee)
Solutions
- Load the project via the bridge's project initialization (initialize_runtime/create with the real .baml source map) before calling functions.
- Verify root_path and src_files actually point at your .baml files and were accepted by the init call.
- Re-initialize the runtime with the full project if state was reset (replace_runtime).
- Add a pre-call check that the project is present and surface a clearer error if not.
Example fix
// before
engine = lib.create_baml_runtime()
lib.call_function(ctx, "ExtractInfo", args) // no project loaded
// after
engine = lib.initialize_runtime("./baml_src", baml_files)
lib.call_function(ctx, "ExtractInfo", args) Defensive patterns
Strategy: validation
Validate before calling
# host side: confirm project sources were passed before calling functions
if not baml_files:
raise ValueError("ProjectNotInitialized guard: pass .baml sources to initialize_runtime") Try / catch
try:
result = lib.call_function(ctx, name, args)
except BridgeError as e:
if "Project not initialized" in str(e):
lib.initialize_runtime(root_path, baml_files)
result = lib.call_function(ctx, name, args)
else:
raise Prevention
- Pair engine creation with project loading in one setup routine; never leave one without the other.
- Verify root_path/src_files point to real .baml files and log how many were loaded.
- After any state reset or hot reload, re-initialize before dispatching calls.
- In tests, use a fixture that guarantees project initialization per test.
When it happens
Trigger: Invoking a bridge operation that requires a loaded project (e.g. calling a function by name, listing functions) after creating a bare runtime without project sources, or after project state was reset/cleared; passing an empty or invalid src_files map during initialization so no project was actually registered.
Common situations: Creating the engine but skipping the project-load step; providing the wrong root_path so no .baml files were discovered; clearing/reloading state between tests and calling a function before reload finishes; embedding via ctypes where only the engine setup wrapper was ported.
Related errors
- Engine not initialized. Call create_baml_runtime first.
- {0}
- unsupported handle type
- {0}
- Protobuf decode error: {0}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/024845f812a216d0.
Report an issue: GitHub.