{"record":{"id":"6d126645c6206e66","repo":"BoundaryML/baml","slug":"callfunctionargs-call-target-must-be-set","errorCode":null,"errorMessage":"CallFunctionArgs.call_target must be set","messagePattern":"CallFunctionArgs\\.call_target must be set","errorType":"exception","errorClass":"BridgeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_cffi/src/error.rs","lineNumber":22,"sourceCode":"\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}'\")]\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\")]","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_cffi/src/error.rs#L4-L40","documentation":"BridgeError::MissingCallTarget from the bridge_cffi crate. It is raised when a call_function operation is invoked with CallFunctionArgs whose call_target field was never set. The bridge needs to know which BAML function to invoke; a null/absent call_target is rejected before any lookup happens.","triggerScenarios":"Calling the bridge's function-invocation entry point with CallFunctionArgs constructed without assigning call_target (e.g. left at its default/None), typically via the CFFI/ctypes layer.","commonSituations":"Hand-building the args struct in FFI bindings and forgetting a field; zero-initialized structs in C/ctypes where an empty string or null target silently passes validation; code generated from outdated bindings missing the call_target field.","solutions":["Set CallFunctionArgs.call_target to the name of the BAML function you want to invoke before calling.","If using ctypes, explicitly assign the field rather than relying on zero-initialized memory.","Regenerate or update FFI bindings so the call_target field exists and is populated.","Add a client-side assert that call_target is a non-empty string before invoking."],"exampleFix":"// before\nlet args = CallFunctionArgs { call_id: 1, ..Default::default() };\n// after\nlet args = CallFunctionArgs { call_id: 1, call_target: Some(\"ExtractResume\".into()), ..Default::default() };","handlingStrategy":"validation","validationCode":"if not args.call_target:\n    raise ValueError(\"call_target must be set before invoking\")","typeGuard":"def has_call_target(args) -> bool:\n    return bool(getattr(args, 'call_target', None))","tryCatchPattern":"try:\n    bridge.call_function(args)\nexcept BridgeError as e:\n    if 'call_target must be set' in str(e):\n        fix_and_retry_with_target(args)","preventionTips":["Always populate call_target at args construction time","Use a constructor/factory that requires the target","Assert non-empty target in FFI wrapper helpers"],"tags":["ffi","validation","missing-field"],"backgroundTag":"missing-required-argument","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"}