{"record":{"id":"30170d56ccd1d16e","repo":"BoundaryML/baml","slug":"unknown-run-verb-flag-stripped-in-script-body-only-function","errorCode":null,"errorMessage":"unknown run-verb flag `--{stripped}` in script body. Only `--function <name>` is recognized before `--`; put target arguments after `--`.","messagePattern":"unknown run-verb flag `--(.+?)` in script body\\. Only `--function <name>` is recognized before `--`; put target arguments after `--`\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/run_command.rs","lineNumber":116,"sourceCode":"\n        // Pre-separator: only `--function <value>` is recognized as a\n        // run-verb flag inside a script body in v1. Other run-verb flags\n        // (`--json-args`, `--include-generated`, etc.) are deliberately rejected\n        // here rather than silently dropped — the toml loader is the\n        // last chance to surface a typo before the script runs.\n        if token == \"--function\" {\n            i += 1;\n            if i < tokens.len() {\n                function = Some(tokens[i].clone());\n                i += 1;\n            } else {\n                anyhow::bail!(\"script body has `--function` without a value\");\n            }\n            continue;\n        }\n\n        if let Some(stripped) = token.strip_prefix(\"--\") {\n            anyhow::bail!(\n                \"unknown run-verb flag `--{stripped}` in script body. \\\n                 Only `--function <name>` is recognized before `--`; \\\n                 put target arguments after `--`.\"\n            );\n        }\n\n        anyhow::bail!(\n            \"unexpected token `{token}` in script body. \\\n             Script bodies have the shape `[--function <name>] [-- <target-args>...]`.\"\n        );\n    }\n\n    Ok(ScriptExpansion {\n        function,\n        extra_args,\n    })\n}\n","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/run_command.rs#L98-L134","documentation":"Parse guard for script bodies in baml.toml [scripts]: a token starting with `--` (other than `--function`) appeared before the `--` separator. V1 deliberately recognizes only `--function <name>` pre-separator; run-verb flags like `--json-args` are rejected at load time rather than silently dropped, because the toml loader is the last chance to surface the typo before the script runs.","triggerScenarios":"`parse_script_body` encounters a token starting with `--` that is not `--function` and not the `--` separator itself, e.g. a script body of `[\"--verbose\", \"--\", \"arg\"]`.","commonSituations":"Putting flags meant for the target function/script (like `--param` or `--file`) before `--`; copying flags from other CLI verbs into the script body.","solutions":["Move target arguments after the `--` separator","Remove the unknown flag if it is not meant for the target","Use `--function <name>` if the intent was to select a BAML function"],"exampleFix":"// before\n[\"--verbose\", \"input.txt\"]\n// after\n[\"--function\", \"MyFunc\", \"--\", \"--verbose\", \"input.txt\"]","handlingStrategy":"validation","validationCode":"function splitScriptBody(tokens) {\n  const sep = tokens.indexOf('--');\n  const head = sep === -1 ? tokens : tokens.slice(0, sep);\n  const bad = head.filter((t, i) => t.startsWith('--') && t !== '--function' && !(t === '--function' && i + 1 < head.length));\n  if (bad.length) throw new Error('move these flags after -- : ' + bad.join(' '));\n}","typeGuard":null,"tryCatchPattern":"try { await baml.run(tokens); } catch (e) { if (String(e).includes('unknown run-verb flag')) { console.error('Only --function is allowed before --; move target args after --'); } else throw e; }","preventionTips":["Put all target-program flags after the `--` separator","Treat the pre-`--` region as reserved for `--function` only","Document the script-body grammar in team runbooks"],"tags":["cli","argument-parsing","baml"],"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-23T08:17:48.524Z"}