{"record":{"id":"32750b0f98f69783","repo":"BoundaryML/baml","slug":"target-function-name-declares-a-parameter-named-help-which","errorCode":null,"errorMessage":"Target `{function_name}` declares a parameter named `help`, which collides with the auto-derived `--help` flag. Rename this parameter to be used as an entry point.","messagePattern":"Target `(.+?)` declares a parameter named `help`, which collides with the auto-derived `--help` flag\\. Rename this parameter to be used as an entry point\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_exec/src/dispatch.rs","lineNumber":37,"sourceCode":"/// Result of dispatching a target.\npub enum DispatchResult {\n    /// Target completed successfully.\n    Ok,\n    /// Target raised an error (already printed to stderr).\n    TargetError,\n    /// Target called `baml.sys.exit(code)`. The caller is responsible for\n    /// terminating the process with this code (clamped to the shell's\n    /// range as appropriate — typically 0..=255 on Unix).\n    Exit(i64),\n}\n\n/// Reject targets whose signature declares a parameter named `help`.\npub fn validate_help_param(engine: &BexEngine, function_name: &str) -> Result<()> {\n    let params = engine\n        .function_params(function_name)\n        .with_context(|| format!(\"failed to resolve target `{function_name}`\"))?;\n    if params.iter().any(|(name, _, _)| *name == \"help\") {\n        anyhow::bail!(\n            \"Target `{function_name}` declares a parameter named `help`, \\\n             which collides with the auto-derived `--help` flag. \\\n             Rename this parameter to be used as an entry point.\"\n        );\n    }\n    Ok(())\n}\n\n/// Narrow a `baml.sys.exit(code)` value (BAML `int` = `i64`) to the `i32`\n/// that `std::process::exit` and C's `exit(int)` take.\npub fn clamp_exit_code(code: i64) -> i32 {\n    i32::try_from(code).unwrap_or(if code < 0 { i32::MIN } else { i32::MAX })\n}\n\n/// Invoke `target_name` with parameters drawn from `cli_values` (and\n/// optionally `json_args`), then write the return value to stdout.\n///\n/// `cli_values` is the already-typed map produced by","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_exec/src/dispatch.rs#L19-L55","documentation":"`--help` is auto-derived by the BAML CLI, so an entry-point function may not declare a parameter literally named `help`. `validate_help_param` scans the target's resolved parameters and bails if any collides, reserving the flag for usage output.","triggerScenarios":"Running or packing a target function whose signature contains a parameter named `help`; the check runs in `run_with_reporter` and again inside `dispatch_target_with_context` under BEP-027 conventions.","commonSituations":"Writing a function that mirrors a CLI-style API with a `help` option, or migrating an existing function whose parameter name happens to be `help`.","solutions":["Rename the `help` parameter in the function signature (e.g. `show_help`, `help_text`).","Update all call sites, test invocations, and any `--json-args` payloads referencing the old name.","Re-run `baml run <target> --help` to confirm the derived flag works."],"exampleFix":"// before\nfunction myFunc(help: bool) { ... }\n\n// after\nfunction myFunc(show_help: bool) { ... }","handlingStrategy":"validation","validationCode":"fn uses_reserved_param(params: &[&str]) -> bool {\n    params.iter().any(|p| *p == \"help\")\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"collides with the auto-derived `--help` flag\") => {\n        eprintln!(\"rename the `help` parameter in the target signature\");\n    }\n    other => other,\n}","preventionTips":["Never name entry-point parameters `help`","Run `baml pack` early; it catches reserved names at pack time","Reserve a documented list of CLI keywords when designing signatures"],"tags":["cli","naming-conflict","reserved-name","baml"],"backgroundTag":"reserved-name-conflict","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"}