zeroclaw-labs/zeroclaw · error · anyhow::Error

grok_cli extra_args accepts long flags only and must not inc

Error message

grok_cli extra_args accepts long flags only and must not include positional arguments

What it means

extra_args accepts long flags only: after trimming, every token must start with '--' and must not be the bare '--' separator. Short flags, positional arguments, and subcommands are rejected outright so they can never be confused with the provider-owned trailing ACP command tokens.

Source

Thrown at crates/zeroclaw-providers/src/grok_cli.rs:555

                // Preserve the operator-supplied spelling; equality is
                // case-insensitive on Windows when checking membership later.
                normalized.push(name.to_string());
            }
        }
        Ok(normalized)
    }

    fn normalize_and_validate_extra_args(extra_args: Vec<String>) -> anyhow::Result<Vec<String>> {
        let extra_args: Vec<String> = extra_args
            .into_iter()
            .map(|arg| arg.trim().to_string())
            .filter(|arg| !arg.is_empty())
            .collect();
        let mut index = 0;
        while index < extra_args.len() {
            let arg = &extra_args[index];
            if arg == "--" || !arg.starts_with("--") {
                anyhow::bail!(
                    "grok_cli extra_args accepts long flags only and must not include positional arguments"
                );
            }
            let (flag, has_inline_value) = arg
                .split_once('=')
                .map_or((arg.as_str(), false), |(flag, _)| (flag, true));
            if RESERVED_EXTRA_ARG_FLAGS.contains(&flag) {
                anyhow::bail!(
                    "grok_cli extra_args must not include reserved flag `{flag}`. \
                     ACP transport, prompt, model, session, cwd, and update policy are owned by ZeroClaw."
                );
            }
            if has_inline_value || VALUELESS_EXTRA_ARG_FLAGS.contains(&flag) {
                index += 1;
                continue;
            }
            if VALUE_TAKING_EXTRA_ARG_FLAGS.contains(&flag) {
                let Some(value) = extra_args.get(index + 1) else {

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Keep only long flags ('--no-plan', '--verbatim') in extra_args
  2. Express values as --flag=value
  3. Drop subcommands and positional file arguments; they are not configurable here

Example fix

# before
extra_args = ["-v", "agent", "stdio"]

# after
extra_args = ["--verbatim"]
Defensive patterns

Strategy: validation

Validate before calling

fn extra_args_shape_ok(args: &[String]) -> bool {
    args.iter().all(|a| a.starts_with("--") && a.as_str() != "--")
}

Type guard

fn extra_args_shape_ok(args: &[String]) -> bool {
    args.iter().all(|a| a.starts_with("--") && a.as_str() != "--")
}

Prevention

When it happens

Trigger: Configuring extra_args = ['-v'], ['agent'], ['--'], or ['--verbatim','notes.txt']; pasting a full grok command line including its subcommand into the list.

Common situations: Migrating a manual `grok ... agent stdio` invocation; muscle-memory short flags; passing file arguments that are positionals.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/e6dc5fc349261436. Report an issue: GitHub.