{"record":{"id":"8195f7e68fccd475","repo":"BoundaryML/baml","slug":"are-mutually-exclusive-dispatch-modes-pick-one","errorCode":null,"errorMessage":"{} are mutually exclusive dispatch modes — pick one.","messagePattern":"(.+?) are mutually exclusive dispatch modes — pick one\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":402,"sourceCode":"        crate::reporter::print_verbose(format_args!(\"profiling: {status}\"));\n    }\n}\n\nimpl RunArgs {\n    fn run_with_reporter(&self, reporter: &Reporter) -> Result<crate::ExitCode> {\n        // Dispatch modes are mutually exclusive. Positional target /\n        // `-f` (one or many) / `-e` all replace each other.\n        let dispatch_modes: &[(&str, bool)] = &[\n            (\"`<target>`\", self.target.is_some()),\n            (\"`-f`\", !self.functions.is_empty()),\n            (\"`-e`\", self.expression.is_some()),\n        ];\n        let used: Vec<&str> = dispatch_modes\n            .iter()\n            .filter_map(|(name, given)| given.then_some(*name))\n            .collect();\n        if used.len() > 1 {\n            anyhow::bail!(\n                \"{} are mutually exclusive dispatch modes — pick one.\",\n                used.join(\" and \")\n            );\n        }\n\n        // `--file` is the standalone-source alternative to `--project`. Both\n        // pointing at sources would be ambiguous (which one wins?), so\n        // reject an explicit combination up front.\n        validate_file_project_flags(self.file.as_deref(), self.from.as_deref())?;\n\n        // Expression mode short-circuits before reaching project / file\n        // loading, so combining `-e` with surfaces that change *what* is\n        // loaded silently does nothing. Reject up front to avoid the\n        // footgun.\n        if self.expression.is_some() {\n            if self.file.is_some() {\n                anyhow::bail!(\n                    \"`-e` is not compatible with `--file`. Expression mode \\","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L384-L420","documentation":"`baml run` supports several mutually exclusive dispatch modes (e.g. `--function`-style script body, expression evaluation, standalone file); more than one was supplied on the command line, so the CLI refuses to guess which to use.","triggerScenarios":"`run_with_reporter` collects which dispatch-mode flags were given and finds more than one set, e.g. passing both an expression and a standalone file mode.","commonSituations":"Combining `--expr` with `--file`, or a script body with another mode in one `baml run` invocation; alias scripts that accumulate flags.","solutions":["Keep only one dispatch mode flag in the command","Run separate invocations for each mode you need","Check your script/alias for accumulated duplicate flags"],"exampleFix":"// before\nbaml run --file script.py --expr 'MyFunc(1)'\n// after\nbaml run --expr 'MyFunc(1)'","handlingStrategy":"validation","validationCode":"function countDispatchModes(flags) {\n  const modes = ['expr', 'file', 'script', 'project'].filter(m => flags[m] !== undefined);\n  if (modes.length > 1) throw new Error('mutually exclusive: ' + modes.join(', '));\n}","typeGuard":null,"tryCatchPattern":"try { await baml.run(args); } catch (e) { if (String(e).includes('mutually exclusive dispatch modes')) { console.error('Pick exactly one dispatch mode'); } else throw e; }","preventionTips":["Supply only one dispatch-mode flag per invocation","Audit shell aliases/scripts for accumulated flags","Parse user input into explicit mode + payload before building argv"],"tags":["cli","argument-parsing","baml"],"backgroundTag":"mutually-exclusive-flags","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"}