nikivdev/code · error

multiple session-doc queue entries match `{session_hint}`

Error message

multiple session-doc queue entries match `{session_hint}`

What it means

The queue resolver accepts a hint that may match by prefix; when more than one queue entry matches, the target is ambiguous so the library refuses to choose. The DECLARED selector here is the `_` arm of the match, i.e. any result with 2+ matches.

Source

Thrown at src/codex_session_docs.rs:1440

    session_hint: &str,
) -> Result<usize> {
    let project_root = project_root.display().to_string();
    let matches = entries
        .iter()
        .enumerate()
        .filter(|(_, entry)| {
            entry.target_root == project_root
                && (entry.session_id == session_hint
                    || entry.session_key == session_hint
                    || entry.session_id.starts_with(session_hint)
                    || entry.session_key.starts_with(session_hint))
        })
        .map(|(index, _)| index)
        .collect::<Vec<_>>();
    match matches.as_slice() {
        [index] => Ok(*index),
        [] => bail!("no session-doc queue entry matches `{session_hint}`"),
        _ => bail!("multiple session-doc queue entries match `{session_hint}`"),
    }
}

fn git_changed_paths(project_root: &Path) -> Result<Vec<String>> {
    let output = Command::new("git")
        .args(["status", "--porcelain", "--untracked-files=all"])
        .current_dir(project_root)
        .output()
        .context("failed to run git status")?;
    if !output.status.success() {
        bail!("git status failed with {}", output.status);
    }
    let stdout = String::from_utf8_lossy(&output.stdout);
    let mut paths = Vec::new();
    for line in stdout.lines() {
        if line.len() < 4 {
            continue;
        }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Provide a longer, unique hint (more characters of the session_key)
  2. Use the full exact session_key from the queue listing
  3. Deduplicate the queue file if genuine duplicate entries exist

Example fix

// before
resolve_entry("se")?; // ambiguous
// after
resolve_entry("sess_1f3a9c")?; // full unique key
Defensive patterns

Strategy: validation

Validate before calling

let count = entries.iter()
    .filter(|e| e.session_key == hint || e.session_key.starts_with(hint)).count();
anyhow::ensure!(count <= 1, "hint `{hint}` is ambiguous ({count} matches); use a longer prefix");

Type guard

fn is_unambiguous_prefix<'a>(entries: &'a [DocReviewQueueEntry], hint: &str) -> Option<&'a DocReviewQueueEntry> {
    let m: Vec<_> = entries.iter().filter(|e| e.session_key.starts_with(hint)).collect();
    match m.as_slice() { [only] => Some(only), _ => None }
}

Try / catch

match resolve_entry(hint) {
    Ok(i) => i,
    Err(e) if e.to_string().contains("multiple session-doc queue entries") => {
        pick_from_listed_matches(hint)?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Passing a short/ambiguous prefix (e.g. "se") that is a prefix of multiple session_keys in the review queue.

Common situations: Users abbreviating session ids too aggressively; sessions with shared id prefixes (same date/branch prefix); duplicate entries appended across runs.

Related errors


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