gitbutlerapp/gitbutler · error
Could not find range from
Error message
Could not find range from '{}' to '{}' in the displayed file list What it means
The CLI range parser (`but` command) resolves a user-supplied range like `file1..file2` against the list of files currently shown in the UI/output. If either endpoint cannot be found in that list, or the position lookup returns None, this error is thrown. It means the range endpoints did not match any displayed file id.
Solutions
- Re-run the command that displays the current file list and copy the exact ids from it.
- Check for typos or stale/expired short ids in the range expression.
- If the file is unlisted, first assign or include it so it appears in the displayed list, then retry.
- Swap or reorder the range if you intended the endpoints in the other direction (both directions are supported, but both must exist).
Example fix
// before but commit 3f9a1..b2c7d // ids from previous session // after but status # refresh displayed list but commit 4d2e0..b2c7d # ids copied from fresh output
Defensive patterns
Strategy: validation
Validate before calling
let displayed = get_displayed_files(); // fresh list from the CLI
for part in [start, end] {
if !displayed.iter().any(|f| f.id_str() == part) {
eprintln!("'{part}' is not in the current file list; refresh with 'but status'");
std::process::exit(1);
}
} Prevention
- Always refresh the file listing immediately before constructing a range.
- Copy-paste ids rather than retyping them.
- Avoid shells expanding `..` or globs in arguments.
When it happens
Trigger: Calling a command that parses a range (via parse_sources_scoped -> try_parse_range) where the start or end token from parts[0]/parts[1] does not exactly match an entry in the currently displayed file list (stale list, typo, file not part of the change set).
Common situations: User typed file names from an older `but` output after files were committed/unassigned; partial or fuzzy ids that don't match; shell expanded glob characters; file exists in the repo but not in the displayed assignment list.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Aborting due to empty branch name
- Unknown theme preset
- Aborting due to empty
- --ai cannot be combined with a resolve subcommand. For one…
- Ambiguous branch ' ', matches multiple items
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/428879ee3fe4cb1e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/id/parser.rs:173
// Both sides must resolve to exactly one Uncommitted entity
if start_matches.len() != 1 || end_matches.len() != 1 {
return Ok(None);
}
if !matches!(&start_matches[0], CliId::UncommittedHunkOrFile(_))
|| !matches!(&end_matches[0], CliId::UncommittedHunkOrFile(_))
{
return Ok(None);
}
// Valid range — resolve positions in display order
let all_files = get_all_files_in_display_order(id_map)?;
let start_pos = all_files.iter().position(|id| id == &start_matches[0]);
let end_pos = all_files.iter().position(|id| id == &end_matches[0]);
match (start_pos, end_pos) {
(Some(s), Some(e)) if s <= e => Ok(Some(all_files[s..=e].to_vec())),
(Some(s), Some(e)) => Ok(Some(all_files[e..=s].to_vec())),
_ => Err(anyhow::anyhow!(
"Could not find range from '{}' to '{}' in the displayed file list",
parts[0],
parts[1]
)),
}
}
fn get_all_files_in_display_order(id_map: &IdMap) -> anyhow::Result<Vec<CliId>> {
let mut files: Vec<(&BStr, CliId)> = id_map
.uncommitted_files
.values()
.map(|uncommitted_file| (uncommitted_file.path(), uncommitted_file.to_id()))
.collect();
files.sort_by_key(|(a_path, _)| *a_path);
Ok(files.into_iter().map(|(_, cli_id)| cli_id).collect())
}
View on GitHub (pinned to 58e5313667)