BoundaryML/baml · error

two `-f` targets share subcommand name `{subcommand}` (`{}`

Error message

two `-f` targets share subcommand name `{subcommand}` (`{}` and `{}`). Subcommand names come from the last `.`-segment of the function name; rename one of them.

What it means

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.

Source

Thrown at baml_language/crates/baml_cli/src/run_command.rs:685

    ) -> Result<(
        Vec<baml_exec::TargetEntry>,
        HashMap<String, UserFunctionInfo>,
    )> {
        let mut entries: Vec<baml_exec::TargetEntry> = Vec::with_capacity(self.functions.len());
        let mut lookups: HashMap<String, UserFunctionInfo> = HashMap::new();
        for func in &self.functions {
            let Some(info) = engine.find_user_function(func) else {
                return Err(Self::function_not_found_error(engine, func));
            };
            baml_exec::validate_help_param(engine, &info.qualified_name)?;
            let display = info
                .qualified_name
                .strip_prefix("user.")
                .unwrap_or(&info.qualified_name)
                .to_string();
            let subcommand = display.rsplit('.').next().unwrap_or(&display).to_string();
            if let Some(prev) = entries.iter().find(|e| e.subcommand_name == subcommand) {
                anyhow::bail!(
                    "two `-f` targets share subcommand name `{subcommand}` \
                     (`{}` and `{}`). Subcommand names come from the last `.`-segment \
                     of the function name; rename one of them.",
                    prev.display_name,
                    display,
                );
            }
            entries.push(baml_exec::TargetEntry {
                qualified_name: info.qualified_name.clone(),
                display_name: display.clone(),
                subcommand_name: subcommand,
            });
            lookups.insert(info.qualified_name.clone(), info);
        }
        Ok((entries, lookups))
    }

    /// Shared tail: spawn the runtime and run dispatch. The program runs

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Rename one of the colliding functions so the last `.`-segment differs
  2. Drop one of the duplicate `-f` targets from the invocation

Example fix

// before
baml run -f Billing.Run -f Analytics.Run
// after
baml run -f Billing.RunBilling -f Analytics.RunReport
Defensive patterns

Strategy: validation

Validate before calling

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(', ')}`);

Prevention

When it happens

Trigger: 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`.

Common situations: Functions with identical short names in different modules/classes being combined into one multi-target invocation.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/f76229b3bf117f82. Report an issue: GitHub.