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 = matchesView on GitHub (pinned to bd85ce9dee)
Solutions
- Remove the forbidden flags from the profile's args in baml.toml; keep only test-filter/log/output flags
- Move project/feature selection to the top-level command invocation instead of inside the profile
- 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
- Keep profile args limited to test filters and log/output flags
- Never paste whole command lines into profile args
- Re-check profiles after adding new top-level CLI flags
- Quote literal values so they are not parsed as flags
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
- script `{target}` has no `--function` and there is no implic
- test profile `{name}` was requested, but {} does not exist
- test profile `{name}` is not defined in {} (available: {avai
- invalid args in test profile `{name}`: {e}
- compilation failed: {e:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/86b32dcdc63f992e.
Report an issue: GitHub.