Hmbown/CodeWhale · error

`codewhale providers export` requires `--json`

Error message

`codewhale providers export` requires `--json`

What it means

`providers export` only supports machine-readable JSON output; invoking it without --json is rejected because the export path has no human-readable rendering, so the missing flag is an invalid usage rather than a formatting choice.

Solutions

  1. Add the flag: `codewhale providers export --json`.
  2. Pipe into jq or a file for consumption: `codewhale providers export --json > providers.json`.
  3. Check `codewhale providers export --help` for the current required flags.

Example fix

// before
codewhale providers export
// after
codewhale providers export --json
Defensive patterns

Strategy: validation

Validate before calling

// shell-side guard
[[ " $* " == *" --json "* ]] || { echo 'providers export requires --json'; exit 2; }

Try / catch

if let Err(e) = run_providers_command(args) {
    if e.to_string().contains("requires `--json`") {
        eprintln!("re-run as: codewhale providers export --json");
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: Running `codewhale providers export` without the `--json` flag.

Common situations: Older workflow or doc example predating the flag requirement; user expecting a human-readable table format; shell alias dropping flags.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/a45b4e0295ee5a8d. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/lib.rs:5497

    }
    if let Some(base_url) = cli.base_url.as_ref() {
        set_tui_env("CODEWHALE_BASE_URL", base_url);
        set_tui_env("DEEPSEEK_BASE_URL", base_url);
    }
}

// There is deliberately no "just run the TUI with these args" helper here. One
// existed, `thread resume`/`thread fork` used it, and it forwarded neither
// `--config` nor the resolved telemetry value — so the kill switch the
// dispatcher had already applied never reached the process that emits. Every
// delegation is now in-process, and
// `only_one_function_may_locate_and_spawn_the_tui` pins that.

fn run_providers_command(args: ProvidersArgs) -> Result<()> {
    match args.command {
        ProvidersCommand::Export { json } => {
            if !json {
                bail!("`codewhale providers export` requires `--json`");
            }
            let export = ProvidersExport::from_registry(env!("CODEWHALE_BUILD_VERSION"));
            serde_json::to_writer_pretty(io::stdout(), &export)
                .context("failed to write providers export")?;
            println!();
            Ok(())
        }
    }
}

fn run_metrics_command(args: MetricsArgs) -> Result<()> {
    let since = match args.since.as_deref() {
        Some(s) => {
            Some(metrics::parse_since(s).with_context(|| format!("invalid --since value: {s:?}"))?)
        }
        None => None,
    };
    metrics::run(metrics::MetricsArgs {

View on GitHub (pinned to 73e0f67d83)