nikivdev/code · error

unsupported `f pr preview --mode` value: {other}

Error message

unsupported `f pr preview --mode` value: {other}

What it means

parse_mode_arg validates the --mode value case-insensitively against "draft" and "feedback". Any other string reaches this error, which echoes the offending value.

Source

Thrown at src/pr_preview.rs:320

                index += 2;
            }
            token => bail!("unknown `f pr preview` option: {token}"),
        }
    }

    Ok(Some(PrPreviewCommand {
        repo_path,
        requested_base,
        mode,
        json,
    }))
}

fn parse_mode_arg(value: &str) -> Result<PrPreviewModeArg> {
    match value.trim().to_ascii_lowercase().as_str() {
        "draft" => Ok(PrPreviewModeArg::Draft),
        "feedback" => Ok(PrPreviewModeArg::Feedback),
        other => bail!("unsupported `f pr preview --mode` value: {other}"),
    }
}

pub fn run_pr_preview(cmd: PrPreviewCommand) -> Result<()> {
    let start = cmd
        .repo_path
        .clone()
        .unwrap_or(std::env::current_dir().context("failed to resolve current directory")?);
    let context = resolve_preview_context(&start)?;
    let packet = build_preview_packet(&context, &cmd)?;
    let result = if packet.diff_stats.files == 0 {
        clear_preview_artifacts(&context.review_root)?;
        PrPreviewRunResult {
            status: "cleared".to_string(),
            source: "flow".to_string(),
            review_root: context.review_root.display().to_string(),
            preview_json_path: context
                .review_root

View on GitHub (pinned to a747e741ae)

Solutions

  1. Use `--mode draft` or `--mode feedback`
  2. Check the exact value in the error message and correct it in scripts
  3. Omit --mode entirely to use the default (draft)

Example fix

// before
f pr preview --mode review
// after
f pr preview --mode feedback
Defensive patterns

Strategy: validation

Validate before calling

let mode = value.trim().to_ascii_lowercase();
if !matches!(mode.as_str(), "draft" | "feedback") {
    anyhow::bail!("mode must be draft or feedback");
}

Try / catch

if let Err(e) = run_pr_preview(cmd) {
    if e.to_string().contains("unsupported `f pr preview --mode` value") {
        eprintln!("Use --mode draft or --mode feedback");
    }
}

Prevention

When it happens

Trigger: Running `f pr preview --mode review` (or any value other than draft/feedback, after trimming and lowercasing).

Common situations: Guessing mode names (e.g. "pr", "open", "ready"); capitalization is tolerated but wrong words are not; scripts with hard-coded invalid modes.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/378722054ecbf47c. Report an issue: GitHub.