{"record":{"id":"b3e89fb84c0342c8","repo":"BoundaryML/baml","slug":"call-id-must-be-a-nonzero-uint64","errorCode":null,"errorMessage":"call_id must be a nonzero uint64","messagePattern":"call_id must be a nonzero uint64","errorType":"exception","errorClass":"BridgeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_cffi/src/error.rs","lineNumber":40,"sourceCode":"    #[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":22,"sourceCodeEnd":49,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_cffi/src/error.rs#L22-L49","documentation":"FFI argument validation error from the bridge_cffi layer: the call_id passed over the C boundary is zero. Call ids are used to correlate in-flight calls with their results, so zero is reserved/invalid; callers must supply a distinct nonzero uint64 for each call.","triggerScenarios":"Passing call_id = 0 (or an unset/default-initialized field) to a call_start or call-related bridge function; passing a value that overflows u64 from a wider client-side integer.","commonSituations":"Zero-initialized C structs in ctypes users who never assign call_id; languages where the default integer is 0; sign/overflow issues when converting from i64 or arbitrary-precision ints.","solutions":["Assign a nonzero call_id (start counters at 1) before invoking.","Validate call_id > 0 client-side before crossing the FFI boundary.","Check integer width conversions so the value fits in uint64.","Explicitly initialize ctypes structs instead of relying on zeroed memory."],"exampleFix":"// before\nargs.call_id = 0;\n// after\nargs.call_id = next_id(); // guaranteed >= 1","handlingStrategy":"validation","validationCode":"if not (0 < call_id <= 2**64 - 1):\n    raise ValueError('call_id must be a nonzero uint64')","typeGuard":"def valid_call_id(v) -> bool:\n    return isinstance(v, int) and 0 < v < 2**64","tryCatchPattern":"try:\n    bridge.call_start(args)\nexcept BridgeError as e:\n    if e is BridgeError.InvalidCallId:\n        args.call_id = next_id()  # starts at 1\n        bridge.call_start(args)","preventionTips":["Start id counters at 1, not 0","Explicitly assign call_id in ctypes structs","Range-check integers before crossing the FFI boundary"],"tags":["ffi","validation","identifier"],"backgroundTag":"value-out-of-range","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"}