{"record":{"id":"ba3d09e00ebe525a","repo":"a-b-street/abstreet","slug":"bad-map-path","errorCode":null,"errorMessage":"bad map path: {}","messagePattern":"bad map path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"map_gui/src/simple_app.rs","lineNumber":84,"sourceCode":"            opts.toggle_day_night_colors = false;\n        }\n    }\n\n    pub fn update_widgetry_settings(&self, mut settings: Settings) -> Settings {\n        settings = settings\n            .read_svg(Box::new(abstio::slurp_bytes))\n            .window_icon(abstio::path(\"system/assets/pregame/icon.png\"));\n        if let Some(s) = self.scale_factor {\n            settings = settings.scale_factor(s);\n        }\n        settings\n    }\n\n    pub fn map_name(&self) -> MapName {\n        self.map_path\n            .as_ref()\n            .map(|path| {\n                MapName::from_path(path).unwrap_or_else(|| panic!(\"bad map path: {}\", path))\n            })\n            .or_else(|| {\n                abstio::maybe_read_json::<crate::tools::DefaultMap>(\n                    abstio::path_player(\"maps.json\"),\n                    &mut Timer::throwaway(),\n                )\n                .ok()\n                .map(|x| x.last_map)\n            })\n            .unwrap_or_else(|| MapName::seattle(\"montlake\"))\n    }\n}\n\nimpl<T: 'static> SimpleApp<T> {\n    pub fn new<\n        F: 'static + Fn(&mut EventCtx, &mut SimpleApp<T>) -> Vec<Box<dyn State<SimpleApp<T>>>>,\n    >(\n        ctx: &mut EventCtx,","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_gui/src/simple_app.rs#L66-L102","documentation":"map_gui's map_name derives the MapName either from the stored map_path (via MapName::from_path) or from the default maps.json in the player data directory. If a map_path is set but cannot be parsed into a MapName, it panics with \"bad map path: {path}\". from_path returns Option (no error detail), so the panic fires for any unparseable path.","triggerScenarios":"Launching the app with a --map path (or loading a saved map_path) whose filename doesn't match the expected `<name>.bin`-style layout that MapName::from_path understands — e.g. wrong directory structure, missing city/country components, or a renamed map file.","commonSituations":"Passing an arbitrary OSM/other .bin file not produced by the importer; moving map files out of the expected data/maps directory; typos in the CLI flag; maps.json absent while map_path is also unset is a separate path — here map_path IS set but malformed.","solutions":["Check the map path matches MapName::from_path's expected format (importer-generated map under the standard data dir with the conventional filename).","Use the app's map picker / change_map_btn to select a valid imported map instead of typing the path.","Re-import the map with the importer so it lands in the canonical location with a canonical name.","Patch from_path to return Result with a reason, or fall back to the default map instead of panicking."],"exampleFix":"// before\nMapName::from_path(path).unwrap_or_else(|| panic!(\"bad map path: {}\", path))\n// after\nmatch MapName::from_path(path) {\n    Some(name) => name,\n    None => {\n        eprintln!(\"unrecognized map path {}, using default\", path);\n        default_map_name()\n    }\n}","handlingStrategy":"validation","validationCode":"let path = std::env::args().find(|a| a.starts_with(\"--map\"));\nif let Some(p) = path {\n    assert!(std::path::Path::new(&p).is_file(), \"map file missing: {}\", p);\n}","typeGuard":null,"tryCatchPattern":"// Panics uncatchably; pre-narrow the path yourself:\nfn valid_map_path(p: &str) -> Option<MapName> {\n    MapName::from_path(p).or_else(|| {\n        eprintln!(\"bad map path {}, falling back to default\", p);\n        None\n    })\n}","preventionTips":["Only pass importer-generated map paths that live under the standard data/maps directory.","Use the in-app map picker rather than hand-typing CLI paths.","Don't rename or relocate imported map .bin files after generation."],"tags":["panic","path-parsing","map-loading","cli-argument"],"backgroundTag":"invalid-argument-format","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"}