{"record":{"id":"0877bf119b2d27fc","repo":"BoundaryML/baml","slug":"invalid-args-in-test-profile-name-e","errorCode":null,"errorMessage":"invalid args in test profile `{name}`: {e}","messagePattern":"invalid args in test profile `(.+?)`: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/test_command.rs","lineNumber":747,"sourceCode":"            if bootstrap {\n                anyhow::bail!(\n                    \"invalid argument `{token}` in test profile `{name}`: profile args cannot contain --profile, --no-profile, --project, --directory, --agent-skill-check, --from, --features, or --help\"\n                );\n            }\n        }\n        if tokens.is_empty() {\n            return Ok(None);\n        }\n        // Parse with the real top-level command grammar so options shown by\n        // `baml test --help` are validated the same way in a profile.\n        let command = crate::commands::RuntimeCli::command();\n        let matches = command\n            .try_get_matches_from(\n                [\"baml\", \"test\"]\n                    .into_iter()\n                    .chain(tokens.iter().map(String::as_str)),\n            )\n            .map_err(|e| anyhow!(\"invalid args in test profile `{name}`: {e}\"))?;\n        let logs_is_explicit = matches\n            .subcommand_matches(\"test\")\n            .and_then(|matches| matches.value_source(\"log\"))\n            == Some(clap::parser::ValueSource::CommandLine);\n        let parsed = crate::commands::RuntimeCli::from_arg_matches(&matches)\n            .map_err(|e| anyhow!(\"invalid args in test profile `{name}`: {e}\"))?;\n        let output = TestOutputOverrides::from_profile_matches(&matches, parsed.output);\n        let crate::commands::Commands::Test(test) = parsed.command else {\n            unreachable!(\"synthetic profile argv always selects the test command\")\n        };\n        Ok(Some(ParsedProfileArgs {\n            logs: logs_is_explicit.then_some(test.log),\n            test,\n            output,\n        }))\n    }\n\n    /// Warm `--list` fast path: render the flattened test list straight from the","sourceCodeStart":729,"sourceCodeEnd":765,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/test_command.rs#L729-L765","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run the flags manually as `baml test <args...>` to see the clap error and fix the profile's args in baml.toml accordingly","Remove or correct the unknown/malformed flag; supply required values for value-taking flags","Update the profile args to match the current baml CLI version (check `baml test --help`)"],"exampleFix":"# before\n[test_profiles.ci]\nargs = [\"--verbos\"]\n\n# after\n[test_profiles.ci]\nargs = [\"--verbose\"]","handlingStrategy":"validation","validationCode":"import subprocess\nr = subprocess.run([\"baml\", \"test\", *profile_args], capture_output=True)\nassert r.returncode == 0, r.stderr.decode()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Test each profile's args directly on the command line first","Run `baml test --help` to confirm flags exist in your CLI version","Update profile args after baml upgrades","Avoid exotic flag/value combinations in profiles"],"tags":["cli","config","baml","clap-parse"],"backgroundTag":"invalid-cli-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}