nikivdev/code · error

`f pr preview --path` accepts at most one repo path override

Error message

`f pr preview --path` accepts at most one repo path override

What it means

The `f pr preview` command accepts at most one `--path` argument to override the repo path. This error is thrown when opts.paths contains more than one entry, since the preview flow can only operate against a single repository.

Source

Thrown at src/pr_preview.rs:270

#[derive(Debug, Clone)]
struct PreviewContext {
    repo_root: PathBuf,
    review_root: PathBuf,
    head_ref: String,
    head_label: String,
    compare_head_label: String,
    work_tree_root: Option<PathBuf>,
}

pub fn parse_pr_preview_args(args: &[String], opts: &PrOpts) -> Result<Option<PrPreviewCommand>> {
    if args.first().map(|value| value.as_str()) != Some("preview") {
        return Ok(None);
    }

    let mut repo_path = match opts.paths.len() {
        0 => None,
        1 => Some(PathBuf::from(&opts.paths[0])),
        _ => bail!("`f pr preview --path` accepts at most one repo path override"),
    };
    let mut requested_base = opts.base.clone();
    let mut mode = opts.mode.unwrap_or(PrPreviewModeArg::Draft);
    let mut json = opts.json;

    let mut index = 1;
    while index < args.len() {
        match args[index].as_str() {
            "--json" => {
                json = true;
                index += 1;
            }
            "--mode" => {
                let Some(value) = args.get(index + 1) else {
                    bail!("`f pr preview --mode` requires a value");
                };
                mode = parse_mode_arg(value)?;
                index += 2;

View on GitHub (pinned to a747e741ae)

Solutions

  1. Pass only a single --path value
  2. Remove duplicate or extra --path arguments from the command line or script
  3. If multiple repos were intended, run `f pr preview` once per repository

Example fix

// before
f pr preview --path ~/repos/api --path ~/repos/web
// after
f pr preview --path ~/repos/api
Defensive patterns

Strategy: validation

Validate before calling

if paths.len() > 1 {
    anyhow::bail!("pass at most one --path to f pr preview");
}

Try / catch

if let Err(e) = run_pr_preview(cmd) {
    if e.to_string().contains("at most one repo path override") {
        eprintln!("Use a single --path; run once per repo instead");
    }
}

Prevention

When it happens

Trigger: Invoking `f pr preview --path /repo/a --path /repo/b` (or otherwise accumulating multiple path overrides) so opts.paths.len() > 1.

Common situations: Scripting the command with repeated --path flags; passing extra positional path arguments assuming multiple repos are supported; copy-pasted command lines from multi-repo workflows.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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