a-b-street/abstreet · error

Can't find

Error message

Can't find {}

What it means

Map::find_r_by_osm_id performs a linear scan over all roads looking for one whose OriginalRoad (orig_id) matches, and bails when no road matches the given OSM-derived ID. The library throws it whenever a caller resolves an OSM way ID to an internal RoadID during import or editing, since the requested road simply does not exist in the map.

Solutions

  1. Verify the OriginalRoad id comes from the same map export as the Map instance (check the map's version/provenance)
  2. Re-import or regenerate the map from current OSM data so the referenced way exists
  3. For stored commands, guard each with map.find_r_by_osm_id(id).is_ok() before applying and skip/regenerate stale ones
  4. Log the unmatched id and confirm it was not renamed; use all_roads() to search for a similar orig_id

Example fix

// before
let r = map.find_r_by_osm_id(OriginalRoad::new(osm_id, way))?;
// after
let r = map.find_r_by_osm_id(OriginalRoad::new(osm_id, way))
    .with_context(|| format!("road {:?} missing from map; re-import needed", way))?;
Defensive patterns

Strategy: try-catch

Validate before calling

fn has_road(map: &Map, id: OriginalRoad) -> bool {
    map.all_roads().any(|r| r.orig_id == id)
}

Type guard

fn road_exists(map: &Map, id: OriginalRoad) -> Option<RoadID> {
    map.find_r_by_osm_id(id).ok()
}

Try / catch

match map.find_r_by_osm_id(orig) {
    Ok(road) => use_road(road),
    Err(e) => { warn!("stale road id {}: {}", orig, e); skip_command(); }
}

Prevention

When it happens

Trigger: Calling find_r_by_osm_id with an OriginalRoad that is not in the map: during import in from_permanent/with_permanent, when applying stored edit commands (fix_old_lane_cmds, into_cmd) that reference roads removed or re-split since the command was recorded, or via lookup/fix_lane_widths with stale IDs.

Common situations: Applying a saved edit/PT route file produced against an older map export; editing OSM upstream so a way ID changed or disappeared; hardcoding an OSM way ID from a different city's map.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13). Data as JSON: /api/errors/6f7968b118ee5eb0. Report an issue: GitHub.

Appendix: source

Thrown at map_model/src/map.rs:731

    /// None for SharedSidewalkCorners and turns not belonging to traffic signals
    pub fn get_movement_for_traffic_signal(
        &self,
        t: TurnID,
    ) -> Option<(MovementID, CompressedMovementID)> {
        let i = self.get_i(t.parent);
        if !i.is_traffic_signal() || self.get_t(t).turn_type == TurnType::SharedSidewalkCorner {
            return None;
        }
        Some(i.turn_to_movement(t))
    }

    pub fn find_r_by_osm_id(&self, id: OriginalRoad) -> Result<RoadID> {
        for r in self.all_roads() {
            if r.orig_id == id {
                return Ok(r.id);
            }
        }
        bail!("Can't find {}", id)
    }

    pub fn find_i_by_osm_id(&self, id: osm::NodeID) -> Result<IntersectionID> {
        for i in self.all_intersections() {
            if i.orig_id == id {
                return Ok(i.id);
            }
        }
        bail!("Can't find {}", id)
    }

    fn populate_intersection_quad_tree(&self) {
        let quad_tree_lock = Arc::clone(&self.intersection_quad_tree);
        let mut quad_tree = quad_tree_lock.write().unwrap();

        if quad_tree.is_some() {
            return;
        }

View on GitHub (pinned to 0964f29315)