{"record":{"id":"6f7968b118ee5eb0","repo":"a-b-street/abstreet","slug":"can-t-find","errorCode":null,"errorMessage":"Can't find {}","messagePattern":"Can't find (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"map_model/src/map.rs","lineNumber":731,"sourceCode":"    /// None for SharedSidewalkCorners and turns not belonging to traffic signals\n    pub fn get_movement_for_traffic_signal(\n        &self,\n        t: TurnID,\n    ) -> Option<(MovementID, CompressedMovementID)> {\n        let i = self.get_i(t.parent);\n        if !i.is_traffic_signal() || self.get_t(t).turn_type == TurnType::SharedSidewalkCorner {\n            return None;\n        }\n        Some(i.turn_to_movement(t))\n    }\n\n    pub fn find_r_by_osm_id(&self, id: OriginalRoad) -> Result<RoadID> {\n        for r in self.all_roads() {\n            if r.orig_id == id {\n                return Ok(r.id);\n            }\n        }\n        bail!(\"Can't find {}\", id)\n    }\n\n    pub fn find_i_by_osm_id(&self, id: osm::NodeID) -> Result<IntersectionID> {\n        for i in self.all_intersections() {\n            if i.orig_id == id {\n                return Ok(i.id);\n            }\n        }\n        bail!(\"Can't find {}\", id)\n    }\n\n    fn populate_intersection_quad_tree(&self) {\n        let quad_tree_lock = Arc::clone(&self.intersection_quad_tree);\n        let mut quad_tree = quad_tree_lock.write().unwrap();\n\n        if quad_tree.is_some() {\n            return;\n        }","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_model/src/map.rs#L713-L749","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the OriginalRoad id comes from the same map export as the Map instance (check the map's version/provenance)","Re-import or regenerate the map from current OSM data so the referenced way exists","For stored commands, guard each with map.find_r_by_osm_id(id).is_ok() before applying and skip/regenerate stale ones","Log the unmatched id and confirm it was not renamed; use all_roads() to search for a similar orig_id"],"exampleFix":"// before\nlet r = map.find_r_by_osm_id(OriginalRoad::new(osm_id, way))?;\n// after\nlet r = map.find_r_by_osm_id(OriginalRoad::new(osm_id, way))\n    .with_context(|| format!(\"road {:?} missing from map; re-import needed\", way))?;","handlingStrategy":"try-catch","validationCode":"fn has_road(map: &Map, id: OriginalRoad) -> bool {\n    map.all_roads().any(|r| r.orig_id == id)\n}","typeGuard":"fn road_exists(map: &Map, id: OriginalRoad) -> Option<RoadID> {\n    map.find_r_by_osm_id(id).ok()\n}","tryCatchPattern":"match map.find_r_by_osm_id(orig) {\n    Ok(road) => use_road(road),\n    Err(e) => { warn!(\"stale road id {}: {}\", orig, e); skip_command(); }\n}","preventionTips":["Always derive OriginalRoad ids from the same map import you query","Version-stamp edit commands with the map import and validate before replay","Prefer iterating all_roads() to build an id->RoadID index once instead of repeated lookups on stale data"],"tags":["rust","osm","lookup-failure"],"backgroundTag":"record-not-found","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}