nikivdev/code · error

Review todo id '{}' is ambiguous

Error message

Review todo id '{}' is ambiguous

What it means

Raised when a review todo operation receives an id that matches multiple review todo entries, so the target cannot be uniquely resolved.

Source

Thrown at src/reviews_todo.rs:149

                .as_deref()
                .map(|r| r.starts_with("flow-review-issue-"))
                .unwrap_or(false)
        })
        .map(|(i, _)| i)
        .collect();

    // Match by id prefix among review items
    let mut matches = Vec::new();
    for &idx in &review_indices {
        if items[idx].id == id || items[idx].id.starts_with(id) {
            matches.push(idx);
        }
    }

    let idx = match matches.len() {
        0 => bail!("Review todo '{}' not found", id),
        1 => matches[0],
        _ => bail!("Review todo id '{}' is ambiguous", id),
    };

    if items[idx].status == "completed" {
        println!("Already completed: {}", items[idx].id);
        return Ok(());
    }

    items[idx].status = "completed".to_string();
    items[idx].updated_at = Some(Utc::now().to_rfc3339());
    todo::save_items(&path, &items)?;
    println!("✓ {} -> completed", items[idx].id);

    Ok(())
}

fn fix_review_todos(id: Option<&str>, all: bool) -> Result<()> {
    let root = todo::project_root();
    let items = todo::load_review_todos(&root)?;

View on GitHub (pinned to a747e741ae)

Solutions

  1. Supply more characters of the id until it is unique
  2. Use the full todo id
  3. List todos first and pick the exact id

Example fix

// before
done_review_todo(root, "a")  // matches a1... and a2...
// after
done_review_todo(root, "a1f3c9de")
Defensive patterns

Strategy: validation

Validate before calling

let ids: Vec<String> = list_review_todos(root)?.iter().map(|t| t.id.clone()).collect();
let n = ids.iter().filter(|i| i.starts_with(prefix)).count();
if n != 1 { eprintln!("prefix {prefix} matches {n} todos; use a longer prefix"); return; }

Try / catch

match done_review_todo(root, prefix) {
    Err(e) if e.to_string().contains("ambiguous") => eprintln!("lengthen the id prefix"),
    other => other?,
}

Prevention

When it happens

Trigger: Calling done with a short id prefix such as "a" when two todos start with "a".

Common situations: Copy-pasting only the first character of an id; shortened ids colliding after many todos accumulate; tab-completion not used.

Related errors


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