Hmbown/CodeWhale · error · io::Error
Ambiguous prefix ' ' matches sessions
Error message
Ambiguous prefix '{}' matches {} sessions What it means
Prefix resolution also rejects a prefix matching more than one session, returning an InvalidInput io::Error listing the match count. The library throws this because it cannot choose between multiple candidates and refuses to pick arbitrarily.
Solutions
- Lengthen the prefix until it uniquely identifies one session (copy more characters from the full id).
- Use the full session id to be unambiguous.
- Enumerate sessions first and disambiguate in your own tooling before resolving.
Example fix
// before
let id = manager.resolve_session_prefix("2026")?; // ambiguous
// after
let id = manager.resolve_session_prefix("20260921-a1b2")?; // longer, unique Defensive patterns
Strategy: validation
Validate before calling
fn prefix_is_unique(prefix: &str, sessions: &[SessionInfo]) -> bool {
sessions.iter().filter(|s| s.id.starts_with(prefix)).count() == 1
} Try / catch
match resolve_session_prefix(prefix) {
Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {
eprintln!("prefix '{prefix}' is ambiguous; use a longer prefix");
Err(e)
}
other => other,
} Prevention
- Use prefixes long enough to be unique (avoid common shared heads like timestamps alone).
- Enumerate candidates yourself when building interactive pickers.
- Prefer full ids in scripts.
When it happens
Trigger: Calling the prefix-resolution API with a prefix shared by two or more session ids (e.g. a single common character or a shared timestamp prefix).
Common situations: Short prefixes in scripts or shell history where many sessions share the leading characters.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- No session found with prefix
- Agent session name ' ' is ambiguous; use an agent_id
- Ambiguous task prefix
- correction must match exactly one active note on the…
- could not resolve spillover path (empty/invalid id or…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/bcdf7d404215ef57.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/session_manager.rs:2499
self.load_session(&self.resolve_session_id_prefix(prefix)?)
}
/// Resolve a unique ID without applying resume-time repair to its record.
pub(crate) fn resolve_session_id_prefix(&self, prefix: &str) -> std::io::Result<String> {
let sessions = self.list_sessions()?;
let matches: Vec<_> = sessions
.into_iter()
.filter(|s| s.id.starts_with(prefix))
.collect();
match matches.len() {
0 => Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
format!("No session found with prefix: {prefix}"),
)),
1 => Ok(matches[0].id.clone()),
_ => Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
format!(
"Ambiguous prefix '{}' matches {} sessions",
prefix,
matches.len()
),
)),
}
}
/// List all saved sessions, sorted by most recently updated
pub fn list_sessions(&self) -> std::io::Result<Vec<SessionMetadata>> {
let mut sessions = Vec::new();
for entry in fs::read_dir(&self.sessions_dir)? {
let entry = entry?;
let path = entry.path();
View on GitHub (pinned to 73e0f67d83)