nikivdev/code · error
`f pr preview --mode` requires a value
Error message
`f pr preview --mode` requires a value
What it means
The `--mode` flag of `f pr preview` requires a value (e.g. draft or feedback). This error is thrown when the flag is the last argument on the command line, so args.get(index + 1) returns None.
Source
Thrown at src/pr_preview.rs:285
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;
}
"--base" => {
let Some(value) = args.get(index + 1) else {
bail!("`f pr preview --base` requires a value");
};
requested_base = value.clone();
index += 2;
}
"--path" => {
let Some(value) = args.get(index + 1) else {
bail!("`f pr preview --path` requires a value");
};
repo_path = Some(PathBuf::from(value));
index += 2;
}View on GitHub (pinned to a747e741ae)
Solutions
- Append a value: `f pr preview --mode draft` (or `feedback`)
- Check shell scripts for truncated or line-wrapped commands
- Ensure the value is not accidentally consumed by quoting issues
Example fix
// before f pr preview --mode // after f pr preview --mode feedback
Defensive patterns
Strategy: validation
Validate before calling
if args.iter().any(|a| a == "--mode") {
let i = args.iter().position(|a| a == "--mode").unwrap();
if args.get(i + 1).is_none() { anyhow::bail!("--mode needs a value"); }
} Try / catch
if let Err(e) = run_pr_preview(cmd) {
if e.to_string().contains("--mode`) requires a value") {
eprintln!("Usage: f pr preview --mode draft|feedback");
}
} Prevention
- Always pass draft or feedback after --mode
- Check scripts for trailing flags at end of line
- Avoid empty shell variables adjacent to flags
When it happens
Trigger: Running `f pr preview --mode` with nothing following it, so no value can be consumed for the flag.
Common situations: Truncated command lines in shell scripts; forgetting to pass draft/feedback after --mode; shell quoting mistakes that drop the value.
Related errors
- `f pr preview --path` accepts at most one repo path override
- `f pr preview --base` requires a value
- `f pr preview --path` requires a value
- unknown `f pr preview` option: {token}
- unsupported `f pr preview --mode` value: {other}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/ae89bfee4f3eda7a.
Report an issue: GitHub.