{"record":{"id":"c6601ec23b6aaaad","repo":"a-b-street/abstreet","slug":"edits-are-for-but-this-map-is","errorCode":null,"errorMessage":"Edits are for {:?}, but this map is {:?}","messagePattern":"Edits are for (.+?), but this map is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"map_model/src/edits/mod.rs","lineNumber":222,"sourceCode":"    /// Load map edits from a JSON file. Strip out any commands that're broken because they don't\n    /// match the current map. If the resulting edits are totally empty, consider that a failure --\n    /// the edits likely don't cover this map at all.\n    pub fn load_from_file(map: &Map, path: String, timer: &mut Timer) -> Result<MapEdits> {\n        let perma = match abstio::maybe_read_json::<PermanentMapEdits>(path.clone(), timer) {\n            Ok(perma) => perma,\n            Err(_) => {\n                // The JSON format may have changed, so attempt backwards compatibility.\n                let bytes = abstio::slurp_file(path)?;\n                let value = serde_json::from_slice(&bytes)?;\n                compat::upgrade(value, map)?\n            }\n        };\n\n        // Don't compare the full MapName; edits in one part of a city could apply to another. But\n        // make sure at least the city matches. Otherwise, we spend time trying to match up edits,\n        // and produce noisy logs along the way.\n        if map.get_name().city != perma.map_name.city {\n            bail!(\n                \"Edits are for {:?}, but this map is {:?}\",\n                perma.map_name.city,\n                map.get_name().city\n            );\n        }\n\n        let edits = perma.into_edits_permissive(map);\n        if edits.commands.is_empty() {\n            bail!(\"None of the edits apply to this map\");\n        }\n        Ok(edits)\n    }\n\n    /// Load map edits from the given JSON bytes. Strip out any commands that're broken because\n    /// they don't match the current map. If the resulting edits are totally empty, consider that a\n    /// failure -- the edits likely don't cover this map at all.\n    pub fn load_from_bytes(map: &Map, bytes: Vec<u8>) -> Result<MapEdits> {\n        let perma = match abstutil::from_json::<PermanentMapEdits>(&bytes) {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_model/src/edits/mod.rs#L204-L240","documentation":"Edits::load_from_file checks that the edit file's recorded map name city matches the loaded map's city before attempting to match commands. Only the city is compared (not the full name, since edits can apply across parts of a city); if they differ, the edits were made for a different map entirely.","triggerScenarios":"Calling Edits::load_from_file (or load_from_bytes) with an edit JSON whose map_name.city differs from map.get_name().city — e.g. loading Seattle edits while a Philadelphia map is open.","commonSituations":"Opening the wrong city's edit file; copying edit files between map directories; renaming/re-importing a map under a different city name.","solutions":["Load the map for the city the edit file was created for (check the file's map_name field).","Open the correct edit file belonging to the currently loaded map.","If the city was intentionally renamed, edit the edit JSON's map_name.city to the new name."],"exampleFix":"// before\nlet edits = Edits::load(map, \"data/player/edits/seattle.json\");\n// after: verify city first\nassert_eq!(map.get_name().city, \"seattle\");\nlet edits = Edits::load(map, \"data/player/edits/seattle.json\");","handlingStrategy":"validation","validationCode":"// read the edit file and compare its city to the loaded map first\nlet v: serde_json::Value = serde_json::from_reader(file)?;\nif v[\"map_name\"][\"city\"] != serde_json::json!(map.get_name().city) {\n    bail!(\"edit file belongs to a different city\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name edit files after their map/city and keep them in matching directories.","Check the map_name field before loading any edit file.","Don't share edit files across cities."],"tags":["edits","map-mismatch","city"],"backgroundTag":"invalid-argument-value","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}