{"record":{"id":"f76229b3bf117f82","repo":"BoundaryML/baml","slug":"two-f-targets-share-subcommand-name-subcommand-and","errorCode":null,"errorMessage":"two `-f` targets share subcommand name `{subcommand}` (`{}` and `{}`). Subcommand names come from the last `.`-segment of the function name; rename one of them.","messagePattern":"two `-f` targets share subcommand name `(.+?)` \\(`(.+?)` and `(.+?)`\\)\\. Subcommand names come from the last `\\.`-segment of the function name; rename one of them\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":685,"sourceCode":"    ) -> Result<(\n        Vec<baml_exec::TargetEntry>,\n        HashMap<String, UserFunctionInfo>,\n    )> {\n        let mut entries: Vec<baml_exec::TargetEntry> = Vec::with_capacity(self.functions.len());\n        let mut lookups: HashMap<String, UserFunctionInfo> = HashMap::new();\n        for func in &self.functions {\n            let Some(info) = engine.find_user_function(func) else {\n                return Err(Self::function_not_found_error(engine, func));\n            };\n            baml_exec::validate_help_param(engine, &info.qualified_name)?;\n            let display = info\n                .qualified_name\n                .strip_prefix(\"user.\")\n                .unwrap_or(&info.qualified_name)\n                .to_string();\n            let subcommand = display.rsplit('.').next().unwrap_or(&display).to_string();\n            if let Some(prev) = entries.iter().find(|e| e.subcommand_name == subcommand) {\n                anyhow::bail!(\n                    \"two `-f` targets share subcommand name `{subcommand}` \\\n                     (`{}` and `{}`). Subcommand names come from the last `.`-segment \\\n                     of the function name; rename one of them.\",\n                    prev.display_name,\n                    display,\n                );\n            }\n            entries.push(baml_exec::TargetEntry {\n                qualified_name: info.qualified_name.clone(),\n                display_name: display.clone(),\n                subcommand_name: subcommand,\n            });\n            lookups.insert(info.qualified_name.clone(), info);\n        }\n        Ok((entries, lookups))\n    }\n\n    /// Shared tail: spawn the runtime and run dispatch. The program runs","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L667-L703","documentation":"Multiple `-f` targets are exposed as subcommands whose names come from the last `.`-segment of each function's name. If two targets produce the same subcommand name, dispatch would be ambiguous, so the CLI rejects the configuration.","triggerScenarios":"Running with several `-f` flags (e.g. `-f a.b.Run -f c.Run`) where both qualified names end in the same segment `Run`, causing a duplicate entry in `resolve_subcommand_targets`.","commonSituations":"Functions with identical short names in different modules/classes being combined into one multi-target invocation.","solutions":["Rename one of the colliding functions so the last `.`-segment differs","Drop one of the duplicate `-f` targets from the invocation"],"exampleFix":"// before\nbaml run -f Billing.Run -f Analytics.Run\n// after\nbaml run -f Billing.RunBilling -f Analytics.RunReport","handlingStrategy":"validation","validationCode":"const segs = fns.map(f => f.replace(/^user\\./, '').split('.').pop()); const dup = segs.filter((s, i) => segs.indexOf(s) !== i); if (dup.length) throw new Error(`duplicate -f subcommand names: ${dup.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure last dot-segments of multi -f function names are unique","Rename functions whose short names collide before combining them in one invocation"],"tags":["cli","conflict","naming","baml"],"backgroundTag":"conflicting-config-options","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"}