{"record":{"id":"5fd3399ceb08935f","repo":"BoundaryML/baml","slug":"type-ty-can-t-be-passed-through-auto-cli-deliver-it-via-json","errorCode":null,"errorMessage":"type `{ty}` can't be passed through auto-CLI; deliver it via `--json-args '{{ \"<param>\": ... }}' (or `--json-args @file` / `--json-args -` for stdin)","messagePattern":"type `(.+?)` can't be passed through auto-CLI; deliver 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/auto_cli.rs","lineNumber":100,"sourceCode":"            }\n        }\n\n        RuntimeTy::Enum(type_name, _) => Ok(BexExternalValue::Variant {\n            enum_name: type_name.display_name().to_string(),\n            variant_name: raw.to_string(),\n        }),\n\n        // Per BEP-027 §\"Open questions\" #5: anything auto-CLI can't\n        // faithfully represent must be delivered via `--json-args`.\n        // Structured types (class/list/map/union) are the obvious case;\n        // media, literals, type aliases, opaque types, and the engine-\n        // internal types (function/void/future) fall in the same\n        // bucket — they either can't survive shell quoting or aren't\n        // valid CLI parameter types. The previous catchall silently\n        // String-coerced everything that fell through; that hides\n        // genuine \"this param can't be passed this way\" errors behind a\n        // confusing downstream type mismatch.\n        _ => anyhow::bail!(\n            \"type `{ty}` can't be passed through auto-CLI; \\\n             deliver it via `--json-args '{{ \\\"<param>\\\": ... }}'` \\\n             (or `--json-args @file` / `--json-args -` for stdin)\"\n        ),\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use baml_type::{MediaKind, TyAttr, TypeName};\n\n    use super::*;\n\n    fn ty_string() -> RuntimeTy {\n        RuntimeTy::String {\n            attr: TyAttr::default(),\n        }\n    }","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_exec/src/auto_cli.rs#L82-L118","documentation":"Auto-CLI only supports passing primitive-typed parameters as raw string flags. Types that can't survive shell quoting or aren't valid CLI parameter types (media, lists, objects, function/void/future, etc.) hit this catchall bail instead of being silently String-coerced. The error directs you to the JSON delivery path.","triggerScenarios":"Supplying a positional/flag value for a parameter whose runtime type falls into the unsupported bucket in `parse_cli_value` (non-primitive, non-nullable-union types like media, maps, lists of media, function/void/future).","commonSituations":"Trying to pass an image or structured object as a CLI flag, or calling an entry point whose signature includes media or complex types without using `--json-args`.","solutions":["Deliver the parameter via `--json-args '{\"<param>\": ...}'`.","Read the payload from a file with `--json-args @file`, or from stdin with `--json-args -`.","If the value should be a simple flag, change the parameter's declared type to a primitive (string/int/float/bool)."],"exampleFix":"// before\nbaml run classify -- --image ./cat.png\n\n// after\nbaml run classify -- --json-args '{\"image\": \"./cat.png\"}'","handlingStrategy":"validation","validationCode":"// before invoking, check the param type in the signature help\nif !matches!(ty, String | Int | Float | Bool) {\n    args.json.insert(name.to_string(), json_value);\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"can't be passed through auto-CLI\") => {\n        eprintln!(\"move this parameter into --json-args\");\n    }\n    other => other,\n}","preventionTips":["Deliver media/object/list parameters via --json-args, not flags","Keep CLI-flag parameters primitive in entry-point signatures","Use --json-args @file for large structured payloads"],"tags":["cli","json","type-mismatch","baml"],"backgroundTag":"invalid-cli-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"}