{"record":{"id":"11e47f57781a7ffe","repo":"BoundaryML/baml","slug":"missing-required-parameter-param-name","errorCode":null,"errorMessage":"Missing required parameter: {param_name}","messagePattern":"Missing required parameter: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs","lineNumber":976,"sourceCode":"        for (param_name, param_type) in function_params {\n            scope.push(param_name.to_string());\n            if let Some(param_value) = params.get(param_name.as_str()) {\n                if let Ok(baml_arg) =\n                    coerce_settings.coerce_arg(self, param_type, param_value, &mut scope)\n                {\n                    baml_arg_map.insert(param_name.to_string(), baml_arg);\n                }\n            } else {\n                // Check if the parameter is optional.\n                if !param_type.is_optional() {\n                    scope.push_error(format!(\"Missing required parameter: {param_name}\"));\n                }\n            }\n            scope.pop(false);\n        }\n\n        if scope.has_errors() {\n            Err(anyhow::anyhow!(scope))\n        } else {\n            Ok(baml_arg_map)\n        }\n    }\n\n    fn get_dummy_args(\n        &self,\n        indent: usize,\n        allow_multiline: bool,\n        params: &BamlMap<String, TypeIR>,\n    ) -> String {\n        params\n            .iter()\n            .map(|(param_name, param_type)| get_dummy_field(self, indent, param_name, param_type))\n            .collect::<Vec<_>>()\n            .join(\"\\n\")\n    }\n}","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/baml-core/src/ir/ir_helpers/mod.rs#L958-L994","documentation":"BAML's `check_function_params` validates that every non-optional parameter of a BAML function is present in the supplied argument map. When a parameter with no default and not declared optional (`T?`) is missing, the error 'Missing required parameter: <name>' is collected into the scope and returned as an anyhow error.","triggerScenarios":"Calling a BAML function (via test runner, client, or runtime arg evaluation) with a params map that omits a parameter declared as required (non-optional) in the .baml function signature.","commonSituations":"Forgetting to pass a newly-added function parameter after editing the .baml file; client SDK generated before the parameter was added; conditionally omitting an argument in code thinking it was optional; null vs absent confusion for optional params.","solutions":["Pass a value for the parameter named in the error when invoking the function","Declare the parameter optional in .baml (`param: string?` or with a default) if it is legitimately omittable","Regenerate the client/SDK after .baml signature changes so new required params are visible","Audit call sites for conditionally-built argument objects and ensure all required keys are always set"],"exampleFix":"// before (.baml)\nfunction Greet(user_name: string) { ... }\n// baml_client.call(\"Greet\", {})  // missing user_name\n\n// after (caller)\nbaml_client.call(\"Greet\", { \"user_name\": \"alice\" })","handlingStrategy":"validation","validationCode":"function assertRequiredParams(params: Record<string, unknown>, required: string[]): void {\n  for (const name of required) {\n    if (!(name in params) || params[name] === undefined) {\n      throw new Error(`Missing required parameter: ${name}`);\n    }\n  }\n}\n// call before baml_client.call(fnName, params)","typeGuard":null,"tryCatchPattern":"try {\n  const res = await baml_client.call('FnName', params);\n} catch (e) {\n  if (String(e).includes('Missing required parameter:')) {\n    const missing = String(e).match(/Missing required parameter: (\\w+)/)?.[1];\n    console.error(`Provide a value (or make optional in .baml) for: ${missing}`);\n  }\n  throw e;\n}","preventionTips":["Regenerate clients whenever the .baml signature changes","Treat non-optional, default-less params as always-present in argument builders","Declare truly optional params as `T?` in .baml","Lint call sites against the function's declared inputs"],"tags":["rust","baml","arguments","validation"],"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-14T11:17:12.474Z"}