{"record":{"id":"9003e0f7c61168a8","repo":"BoundaryML/baml","slug":"generic-function-must-have-a-type-argument-try-adding-a-type","errorCode":null,"errorMessage":"Generic function {} must have a type argument. Try adding a type argument like this: {}<Type>","messagePattern":"Generic function (.+?) must have a type argument\\. Try adding a type argument like this: (.+?)<Type>","errorType":"validation","errorClass":"DatamodelError","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs","lineNumber":309,"sourceCode":"                    anyhow::anyhow!(\"Unknown variable {}\", &identifier.to_string()),\n                    identifier.span().clone(),\n                ));\n            }\n        }\n        Expression::Lambda(_args, _body, _span) => {}\n        Expression::App(app) => {\n            // Validate the function name.\n            if !scope.contains(app.name.name()) {\n                ctx.push_error(DatamodelError::new_anyhow_error(\n                    anyhow::anyhow!(\"Unknown function {}\", &app.name.to_string()),\n                    app.span().clone(),\n                ));\n            }\n\n            // Validate generics.\n            if ir::builtin::is_builtin_identifier(app.name.name()) && app.type_args.is_empty() {\n                ctx.push_error(DatamodelError::new_anyhow_error(\n                    anyhow::anyhow!(\n                        \"Generic function {} must have a type argument. Try adding a type argument like this: {}<Type>\",\n                        app.name.name(),\n                        app.name.name()\n                    ),\n                    app.span().clone(),\n                ));\n            }\n            for arg in &app.args {\n                validate_expression(ctx, arg, scope);\n            }\n        }\n        Expression::Array(items, _span) => {\n            for item in items {\n                validate_expression(ctx, item, scope);\n            }\n        }\n        Expression::Map(fields, _span) => {\n            for (_key, value) in fields {","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/validate/validation_pipeline/validations/expr_fns.rs#L291-L327","documentation":"Builtin generic functions (e.g. type-level builtins like map/filter style generics) must be instantiated with explicit type arguments. Applying a builtin identifier with an empty type_args list triggers this error with a suggested `<Type>` syntax.","triggerScenarios":"Using a builtin generic identifier in an App expression without any `<...>` type arguments, detected when is_builtin_identifier(name) && type_args.is_empty().","commonSituations":"Writing builtins like `map`/`filter`-style generics without their type parameter, after upgrading BAML where type arguments became mandatory for a builtin.","solutions":["Add explicit type arguments: functionName<Type>","Consult builtin docs for the expected number of type arguments","Update code to the newer generic-call syntax after BAML version upgrades"],"exampleFix":"// before\nlet r = map(items, f)\n// after\nlet r = map<string>(items, f)","handlingStrategy":"validation","validationCode":"// Require type args on builtin generics before compiling\nif is_builtin_identifier(call.name) && call.type_args.is_empty() {\n    bail!(\"builtin {} requires a <Type> argument\", call.name);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write explicit type arguments on builtin generics","Check builtin signatures in BAML docs when upgrading versions","Let the LSP insert generic placeholders"],"tags":["baml","validation","generics","builtin"],"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-23T08:17:48.524Z"}