{"record":{"id":"dfd2716a2fc2d185","repo":"BoundaryML/baml","slug":"missing-required-argument-name-type-ty-pass-it-via-json-args","errorCode":null,"errorMessage":"missing required argument `{name}` (type: {ty}).\npass it via `--json-args '{{\"{name}\": ...}}'` (or `--json-args @file` / `--json-args -` for stdin).","messagePattern":"missing required argument `(.+?)` \\(type: (.+?)\\)\\.\npass it via `--json-args '(.+?)\": \\.\\.\\.\\}\\}'` \\(or `--json-args @file` / `--json-args -` for stdin\\)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_exec/src/dispatch.rs","lineNumber":257,"sourceCode":"            }\n            None if has_default => ordered.push(BexCallArg::OmittedDefault),\n            None => {\n                // Primitive params should have been caught by clap as\n                // required flags — if we get here, either the caller\n                // (test) bypassed clap or the param is non-primitive\n                // (class/list/map/union/etc.), which has no `--name`\n                // flag and is only deliverable via `--json-args`. Point\n                // at `--json-args` for non-primitives so the hint\n                // matches the help-block guidance; keep the legacy\n                // `--name`-after-`--` hint for primitives so test\n                // expectations and bare engine callers stay friendly.\n                if crate::is_auto_cli_primitive(ty) {\n                    anyhow::bail!(\n                        \"missing required argument `--{name}` (type: {ty}).\\n\\\n                         pass it after `--`: `... -- --{name} <value>`\"\n                    );\n                }\n                anyhow::bail!(\n                    \"missing required argument `{name}` (type: {ty}).\\n\\\n                     pass it via `--json-args '{{\\\"{name}\\\": ...}}'` \\\n                     (or `--json-args @file` / `--json-args -` for stdin).\"\n                );\n            }\n        }\n    }\n\n    if !merged.is_empty() {\n        let unknown: Vec<&str> = merged.keys().map(String::as_str).collect();\n        crate::print_warning(format_args!(\n            \"unknown argument(s) ignored: {}\",\n            unknown.join(\", \")\n        ));\n    }\n\n    Ok(ordered)\n}","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_exec/src/dispatch.rs#L239-L275","documentation":"Same missing-required-argument condition as the primitive variant, but for non-primitive types (media, objects, lists, etc.). Because those values can't be passed as raw shell flags, the error directs you to `--json-args`, including the `@file` and stdin (`-`) forms.","triggerScenarios":"Dispatching a target with a required non-primitive parameter that was not provided in `--json-args` (inline, `@file`, or `-`); `build_args_from_signature_with_context` bails after failing the `is_auto_cli_primitive` check.","commonSituations":"Forgetting a structured/media parameter entirely, supplying only the primitive ones, or passing a non-primitive as a positional flag (which would instead hit the can't-be-passed error) rather than via JSON.","solutions":["Pass the parameter via `--json-args '{\"<name>\": ...}'`.","Use `--json-args @file` for large payloads or `--json-args -` to pipe from stdin.","Make the parameter optional in the function signature if it genuinely has no required value."],"exampleFix":"// before\nbaml run analyze -- --json-args '{}'\n\n// after\nbaml run analyze -- --json-args '{\"image\": \"./cat.png\", \"options\": {\"mode\": \"fast\"}}'","handlingStrategy":"validation","validationCode":"for (name, ty, required) in signature.params {\n    if required && !is_primitive(ty) && !json_args_keys.contains(name) {\n        eprintln!(\"supply {name} ({ty}) via --json-args\");\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"pass it via `--json-args`\") => {\n        eprintln!(\"add the parameter to --json-args or @file/stdin\");\n    }\n    other => other,\n}","preventionTips":["Build complete --json-args objects covering all required non-primitive params","Use --json-args @file to keep complex payloads maintainable","Review entry-point signatures when tests fail with missing-argument errors"],"tags":["cli","missing-argument","json","baml"],"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"}