{"record":{"id":"024845f812a216d0","repo":"BoundaryML/baml","slug":"project-not-initialized","errorCode":null,"errorMessage":"Project not initialized","messagePattern":"Project not initialized","errorType":"exception","errorClass":"BridgeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_cffi/src/error.rs","lineNumber":13,"sourceCode":"//! Error types for bridge_cffi.\n\nuse thiserror::Error;\n\n/// Errors that can occur during bridge operations.\n#[derive(Debug, Error)]\npub enum BridgeError {\n    #[error(transparent)]\n    Ctypes(#[from] bridge_ctypes::CtypesError),\n    #[error(\"Engine not initialized. Call create_baml_runtime first.\")]\n    NotInitialized,\n\n    #[error(\"Project not initialized\")]\n    ProjectNotInitialized,\n\n    #[error(\"Engine lock poisoned\")]\n    LockPoisoned,\n\n    #[error(\"{0}\")]\n    Runtime(#[from] bex_project::RuntimeError),\n\n    #[error(\"CallFunctionArgs.call_target must be set\")]\n    MissingCallTarget,\n\n    #[error(\"type arguments are not supported when invoking a BAML function handle\")]\n    FunctionHandleTypeArgs,\n\n    #[error(\"Function not found: {name}\")]\n    FunctionNotFound { name: String },\n\n    #[error(\"Missing argument '{parameter}' for function '{function}'\")]","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_cffi/src/error.rs#L1-L31","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nengine = lib.create_baml_runtime()\nlib.call_function(ctx, \"ExtractInfo\", args)  // no project loaded\n// after\nengine = lib.initialize_runtime(\"./baml_src\", baml_files)\nlib.call_function(ctx, \"ExtractInfo\", args)","handlingStrategy":"validation","validationCode":"# host side: confirm project sources were passed before calling functions\nif not baml_files:\n    raise ValueError(\"ProjectNotInitialized guard: pass .baml sources to initialize_runtime\")","typeGuard":null,"tryCatchPattern":"try:\n    result = lib.call_function(ctx, name, args)\nexcept BridgeError as e:\n    if \"Project not initialized\" in str(e):\n        lib.initialize_runtime(root_path, baml_files)\n        result = lib.call_function(ctx, name, args)\n    else:\n        raise","preventionTips":["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."],"tags":["initialization","ffi","project-setup","rust"],"backgroundTag":"missing-configuration","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}