{"record":{"id":"7fc32427480adebe","repo":"BoundaryML/baml","slug":"future-with-id-future-id-not-found","errorCode":null,"errorMessage":"Future with ID {future_id} not found","messagePattern":"Future with ID (.+?) not found","errorType":"exception","errorClass":"EngineError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bex_engine/src/lib.rs","lineNumber":804,"sourceCode":"        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}\")]\n    VmInternalError(bex_vm::errors::VmInternalError),\n\n    #[error(\"{}\", format_vm_internal_error(source, trace))]","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bex_engine/src/lib.rs#L786-L822","documentation":"`EngineError::FutureNotFound` is raised when a `FutureId` cannot be resolved in the engine's future table. Futures are registered when spawned and removed once resolved or dropped; an unknown ID means it never existed here, was already completed, or was discarded.","triggerScenarios":"Polling, completing, or fetching the result of a future by an ID that the engine has already reaped or never issued.","commonSituations":"Double-awaiting a future's result; holding future IDs across engine shutdown/restart; ID mixups when multiple engines run concurrently.","solutions":["Await each future exactly once and drop the ID afterwards.","Obtain fresh `FutureId`s from the current engine instance.","Verify the future was spawned on the same engine being queried."],"exampleFix":"// before\nlet a = engine.future_result(fid).await?;\nlet b = engine.future_result(fid).await?; // second lookup fails\n// after\nlet a = engine.future_result(fid).await?;\n// do not reuse fid after completion","handlingStrategy":"try-catch","validationCode":"// keep a local registry of pending FutureIds issued by this engine","typeGuard":null,"tryCatchPattern":"// rust\nmatch engine.future_result(fid).await {\n    Err(EngineError::FutureNotFound { .. }) => /* future already resolved or foreign */,\n    other => other?,\n}","preventionTips":["Await each future exactly once","Do not reuse FutureIds or share them between engines","Clear pending-future bookkeeping on shutdown"],"tags":["engine","async","futures","rust"],"backgroundTag":"resource-not-found","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"}