nikivdev/code · error · anyhow::Error
Route not found: {}
Error message
Route not found: {} What it means
run_rm removes a host route from the domains config. load_routes builds the map, and if routes.remove(&host) returns None the host was never registered, so the command aborts rather than writing a no-op change.
Source
Thrown at src/domains.rs:210
existing
);
}
}
routes.insert(host.clone(), target.clone());
save_routes(paths, &routes)?;
write_route_files(paths, &routes)?;
maybe_reload_running_proxy(paths, engine)?;
println!("Added route: {host} -> {target}");
Ok(())
}
fn run_rm(paths: &DomainsPaths, opts: DomainsRmOpts, engine: DomainsEngine) -> Result<()> {
ensure_layout(paths)?;
let host = normalize_host(&opts.host)?;
let mut routes = load_routes(paths)?;
if routes.remove(&host).is_none() {
bail!("Route not found: {}", host);
}
save_routes(paths, &routes)?;
write_route_files(paths, &routes)?;
maybe_reload_running_proxy(paths, engine)?;
println!("Removed route: {host}");
Ok(())
}
fn run_doctor(paths: &DomainsPaths, engine: DomainsEngine) -> Result<()> {
if engine == DomainsEngine::Native {
return run_doctor_native(paths);
}
ensure_layout(paths)?;
let routes = load_routes(paths)?;
println!("Local domains doctor");
println!("--------------------");
println!("Config root: {}", paths.root.display());View on GitHub (pinned to a747e741ae)
Solutions
- List existing routes to find the exact registered host
- Re-run with the exact host string stored in the routes file (e.g. linsa.localhost)
- Treat the error as confirmation if the route was already removed
Example fix
// before f domains rm linsa.localhost # Route not found: linsa.localhost // after f domains list # find registered host f domains rm myapp.localhost
Defensive patterns
Strategy: validation
Validate before calling
let routes = load_routes(&paths)?;
let host = normalize_host(&opts.host)?;
if !routes.contains_key(&host) {
eprintln!("{host} is not registered; run the list command to see routes");
} Try / catch
match result {
Err(e) if e.to_string().starts_with("Route not found:") => {
eprintln!("Check the exact host with the list subcommand.");
}
other => other?,
} Prevention
- Normalize hosts the same way the tool does before looking them up
- List routes before removing
- Make removal idempotent in scripts (ignore 'Route not found')
When it happens
Trigger: `domains rm <host>` where the normalized host is absent from the routes file.
Common situations: Typos in the host name, host stored with a different subdomain than typed, removing a route that was already deleted in another terminal, or clean environments where no routes were ever added.
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
- Review todo '{}' not found
- Review todo '{}' not found among open items
- Failure '{}' not found. Run `f failure list` to inspect rece
- Session '{}' not found in saved sessions
- Session not found
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/c746b60c65b3d9b2.
Report an issue: GitHub.