{"record":{"id":"598c402bcbc41cf5","repo":"BoundaryML/baml","slug":"type-arguments-are-not-supported-when-invoking-a-baml","errorCode":null,"errorMessage":"type arguments are not supported when invoking a BAML function handle","messagePattern":"type arguments are not supported when invoking a BAML function handle","errorType":"exception","errorClass":"BridgeError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/bridge_cffi/src/error.rs","lineNumber":25,"sourceCode":"pub 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\")]\n    InvalidCallId,\n\n    #[error(\"Internal error: {0}\")]","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/bridge_cffi/src/error.rs#L7-L43","documentation":"BridgeError::FunctionHandleTypeArgs. When invoking an already-resolved BAML function handle, supplying type arguments is not supported because the handle is bound to a concrete function signature. The bridge rejects type arguments to avoid ambiguity about which instantiation to run.","triggerScenarios":"Calling a BAML function through a function handle while passing type arguments (generics/type parameters) in the invocation args.","commonSituations":"Porting generic-language call sites (TypeScript generics, Python type hints) to the FFI boundary and passing type args along; copying an invocation pattern from direct function calls, which may accept type args, to handle-based calls.","solutions":["Remove type arguments from the handle-based invocation and call the handle directly.","Resolve the desired typed function into a concrete handle instead of parameterizing at call time.","If type selection matters, look up the specific function variant by name as call_target."],"exampleFix":"// before\ninvoke(handle, type_args = [\"MyOutputType\"], args);\n// after\ninvoke(handle, args);","handlingStrategy":"validation","validationCode":"if getattr(args, 'type_args', None):\n    raise ValueError('type args are not supported for function handles')","typeGuard":"def type_args_empty(args) -> bool:\n    return not getattr(args, 'type_args', None)","tryCatchPattern":"try:\n    invoke(handle, args)\nexcept BridgeError as e:\n    if 'type arguments are not supported' in str(e):\n        invoke(handle, strip_type_args(args))","preventionTips":["Never pass type arguments through handle-based invocations","Resolve concrete functions by name instead of parameterizing handles"],"tags":["ffi","generics","unsupported"],"backgroundTag":"unsupported-operation","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"}