BoundaryML/baml · error

invalid args in test profile `{name}`: {e}

Error message

invalid args in test profile `{name}`: {e}

What it means

parse_profile_args feeds the profile's tokens as a synthetic `baml test ...` argv into a clap Command via try_get_matches_from; a clap parsing failure (unknown flag, missing value, bad subcommand shape) is wrapped in this anyhow error. It surfaces clap's own message with the profile name for context.

Source

Thrown at baml_language/crates/baml_cli/src/test_command.rs:747

            if bootstrap {
                anyhow::bail!(
                    "invalid argument `{token}` in test profile `{name}`: profile args cannot contain --profile, --no-profile, --project, --directory, --agent-skill-check, --from, --features, or --help"
                );
            }
        }
        if tokens.is_empty() {
            return Ok(None);
        }
        // Parse with the real top-level command grammar so options shown by
        // `baml test --help` are validated the same way in a profile.
        let command = crate::commands::RuntimeCli::command();
        let matches = command
            .try_get_matches_from(
                ["baml", "test"]
                    .into_iter()
                    .chain(tokens.iter().map(String::as_str)),
            )
            .map_err(|e| anyhow!("invalid args in test profile `{name}`: {e}"))?;
        let logs_is_explicit = matches
            .subcommand_matches("test")
            .and_then(|matches| matches.value_source("log"))
            == Some(clap::parser::ValueSource::CommandLine);
        let parsed = crate::commands::RuntimeCli::from_arg_matches(&matches)
            .map_err(|e| anyhow!("invalid args in test profile `{name}`: {e}"))?;
        let output = TestOutputOverrides::from_profile_matches(&matches, parsed.output);
        let crate::commands::Commands::Test(test) = parsed.command else {
            unreachable!("synthetic profile argv always selects the test command")
        };
        Ok(Some(ParsedProfileArgs {
            logs: logs_is_explicit.then_some(test.log),
            test,
            output,
        }))
    }

    /// Warm `--list` fast path: render the flattened test list straight from the

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Run the flags manually as `baml test <args...>` to see the clap error and fix the profile's args in baml.toml accordingly
  2. Remove or correct the unknown/malformed flag; supply required values for value-taking flags
  3. Update the profile args to match the current baml CLI version (check `baml test --help`)

Example fix

# before
[test_profiles.ci]
args = ["--verbos"]

# after
[test_profiles.ci]
args = ["--verbose"]
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
r = subprocess.run(["baml", "test", *profile_args], capture_output=True)
assert r.returncode == 0, r.stderr.decode()

Prevention

When it happens

Trigger: A profile's args in baml.toml contain a flag clap does not recognize for the test command, a flag missing its required value, or a value in an invalid form (e.g. `--log` without a value, unknown subcommand token).

Common situations: Typos in flags inside profile args; flags valid on other baml commands but not `test`; version drift where a profile was written for an older CLI whose flags changed; missing value after a flag.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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