BoundaryML/baml · error

invalid argument `{token}` in test profile `{name}`: profile

Error message

invalid argument `{token}` in test profile `{name}`: profile args cannot contain --profile, --no-profile, --project, --directory, --agent-skill-check, --from, --features, or --help

What it means

Test profile args in baml.toml are parsed as a synthetic `baml test` argv, but arguments that select profiles, projects, features, or help would create recursive/ambiguous behavior, so parse_profile_args rejects them upfront with this bail. This keeps profile definitions from re-entering the same CLI-selection machinery.

Source

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

            let bootstrap = matches!(
                token.as_str(),
                "--profile"
                    | "--no-profile"
                    | "--project"
                    | "--directory"
                    | "--agent-skill-check"
                    | "--from"
                    | "--features"
                    | "--help"
                    | "-h"
            ) || token.starts_with("--profile=")
                || token.starts_with("--project=")
                || token.starts_with("--directory=")
                || token.starts_with("--agent-skill-check=")
                || token.starts_with("--from=")
                || token.starts_with("--features=");
            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

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Remove the forbidden flags from the profile's args in baml.toml; keep only test-filter/log/output flags
  2. Move project/feature selection to the top-level command invocation instead of inside the profile
  3. Rename the token if it was meant as a literal value, quoting it so it is not parsed as a flag

Example fix

# before
[test_profiles.ci]
args = ["--from", "main", "--features", "plus"]

# after
[test_profiles.ci]
args = ["--all"]
# run: baml test --from main --features plus --profile ci
Defensive patterns

Strategy: validation

Validate before calling

FORBIDDEN = {"--profile", "--no-profile", "--project", "--directory", "--agent-skill-check", "--from", "--features", "--help"}
for tok in profile_args:
    base = tok.split("=", 1)[0]
    assert base not in FORBIDDEN, f"forbidden flag in profile args: {tok}"

Prevention

When it happens

Trigger: A profile's `args` list in baml.toml (or a --profile arg expansion) contains any of: --profile/--profile=, --no-profile, --project(=), --directory(=), --agent-skill-check(=), --from(=), --features(=), or --help.

Common situations: Copy-pasting full command lines into a profile's args; trying to chain profiles or override the project root inside a profile; adding --features flags to profiles; accidentally including --help.

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/86b32dcdc63f992e. Report an issue: GitHub.