{"record":{"id":"c6230c2dccc42078","repo":"BoundaryML/baml","slug":"function-call-with-id-call-id-not-found","errorCode":null,"errorMessage":"Function call with ID {call_id} not found","messagePattern":"Function call with ID (.+?) not found","errorType":"exception","errorClass":"EngineError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_engine/src/lib.rs","lineNumber":801,"sourceCode":"            .active_calls\n            .lock()\n            .unwrap_or_else(std::sync::PoisonError::into_inner);\n        map.remove(&self.call_id);\n        let no_active_calls = map.values().all(|call| call.pending);\n        drop(map);\n        if no_active_calls {\n            self.engine.lifecycle_changed.notify_waiters();\n        }\n    }\n}\n\n/// Errors that can occur during engine execution.\n#[derive(Debug, PartialEq, Error, Clone)]\npub enum EngineError {\n    #[error(\"BAML engine is shutting down\")]\n    ShuttingDown,\n\n    #[error(\"Function call with ID {call_id} not found\")]\n    FunctionCallNotFound { call_id: CallId },\n\n    #[error(\"Future with ID {future_id} not found\")]\n    FutureNotFound { future_id: FutureId },\n\n    #[error(\"Function not found: {name}\")]\n    FunctionNotFound { name: String },\n\n    /// Function exists, but its `FunctionKind` is not invokable as an\n    /// engine entry point. Only bytecode functions can be called via\n    /// [`BexEngine::call_function`] / [`BexEngine::call_function_bound_args`]:\n    /// native (`$rust_function`) entries would re-enter the VM through\n    /// `YieldToCall` with no bytecode frame to return to. Sysops + builtins\n    /// reach their natives from inside a calling bytecode body.\n    #[error(\"Function `{name}` is not invokable as an entry point (kind: {kind})\")]\n    NotInvokableAsEntry { name: String, kind: String },\n\n    #[error(\"VM internal error: {0}\")]","sourceCodeStart":783,"sourceCodeEnd":819,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_engine/src/lib.rs#L783-L819","documentation":"`EngineError::FunctionCallNotFound` is raised when the engine is asked about a function call whose `CallId` it does not track. Call IDs are engine-scoped handles; an unknown ID means the call was never registered, already completed and was reaped, or belongs to a different engine instance.","triggerScenarios":"Looking up, awaiting, or cancelling a call with a fabricated, expired, or foreign `CallId` via the engine's call-tracking APIs.","commonSituations":"Persisting a call ID across engine restarts; awaiting a call after it completed and its record was dropped; mixing IDs between two engine instances in tests.","solutions":["Use only `CallId`s returned by this engine instance in this session.","Check that the call has not already completed and been cleaned up.","Re-issue the call to obtain a fresh ID instead of reusing a stale one."],"exampleFix":"// before\nlet result = engine.call_result(stale_call_id).await?;\n// after\nlet call_id = engine.call_function(\"f\", args).await?;\nlet result = engine.call_result(call_id).await?;","handlingStrategy":"try-catch","validationCode":"// track CallIds only from the live engine instance; drop after completion","typeGuard":null,"tryCatchPattern":"// rust\nmatch engine.call_result(call_id).await {\n    Err(EngineError::FunctionCallNotFound { .. }) => /* re-issue the call */,\n    other => other?,\n}","preventionTips":["Never persist CallIds across engine restarts","Await each call once; treat IDs as single-use","Scope call tracking to the engine instance that issued the ID"],"tags":["engine","lookup","lifecycle","rust"],"backgroundTag":"record-not-found","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"}