{"record":{"id":"8b60f13233c7643d","repo":"BoundaryML/baml","slug":"call-id-0-is-already-in-use-by-an-active-call","errorCode":null,"errorMessage":"call_id {0} is already in use by an active call","messagePattern":"call_id (.+?) is already in use by an active call","errorType":"exception","errorClass":"BridgeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_cffi/src/error.rs","lineNumber":37,"sourceCode":"    #[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}'\")]\n    MissingArgument { function: String, parameter: String },\n\n    #[error(\"Not implemented: {0}\")]\n    NotImplemented(String),\n\n    #[error(\"call_id {0} is already in use by an active call\")]\n    DuplicateCallId(u64),\n\n    #[error(\"call_id must be a nonzero uint64\")]\n    InvalidCallId,\n\n    #[error(\"Internal error: {0}\")]\n    Internal(String),\n\n    #[error(\"{0}\")]\n    Startup(String),\n}\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_cffi/src/error.rs#L19-L49","documentation":"BridgeError::DuplicateCallId carries the conflicting id. The bridge tracks in-flight calls by call_id so results can be routed back to the right caller; registering a new call with an id that already belongs to an active call is rejected to prevent result cross-wiring.","triggerScenarios":"Starting a new asynchronous bridge call with a call_id equal to one from a call that has not yet completed or been consumed; reusing ids without waiting for completion; calling code that resets its id counter while calls are still active.","commonSituations":"Retry logic re-submitting with the same id after a timeout while the original call still runs; id generators restarting per process/thread; forgetting to retrieve or cancel a pending call before issuing the next.","solutions":["Generate unique call_ids (e.g. monotonic counter or UUID-derived integer) for every call.","Wait for or cancel the active call holding that id before reusing it.","Fix id generators that reset between retries or threads.","Consume pending results promptly so ids retire."],"exampleFix":"// before\nlet call_id = 42; // reused every call\n// after\nstatic NEXT_ID: AtomicU64 = AtomicU64::new(1);\nlet call_id = NEXT_ID.fetch_add(1, Ordering::Relaxed);","handlingStrategy":"validation","validationCode":"if call_id in active_calls:\n    raise ValueError(f'call_id {call_id} still active')","typeGuard":null,"tryCatchPattern":"try:\n    bridge.call_start(args)\nexcept BridgeError as e:\n    if e is BridgeError.DuplicateCallId:\n        args.call_id = new_unique_id()\n        bridge.call_start(args)","preventionTips":["Use a process-wide monotonic id generator","Never reset id counters while calls are pending","Complete or cancel calls before reusing ids"],"tags":["ffi","concurrency","identifier"],"backgroundTag":"invalid-argument-value","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"}