{"record":{"id":"c7d8387af40730a8","repo":"a-b-street/abstreet","slug":"couldn-t-load-edits","errorCode":null,"errorMessage":"Couldn't load edits \"{}\": {}","messagePattern":"Couldn't load edits \"(.+?)\": (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sim/src/make/load.rs","lineNumber":98,"sourceCode":"        let mut opts = self.opts.clone();\n\n        if self.load.starts_with(&abstio::path_player(\"saves/\")) {\n            info!(\"Resuming from {}\", self.load);\n\n            let sim: Sim = abstio::must_read_object(self.load.clone(), timer);\n\n            let mut map = Map::load_synchronously(sim.map_name.path(), timer);\n            match MapEdits::load_from_file(\n                &map,\n                abstio::path_edits(map.get_name(), &sim.edits_name),\n                timer,\n            ) {\n                Ok(edits) => {\n                    map.must_apply_edits(edits, timer);\n                    map.recalculate_pathfinding_after_edits(timer);\n                }\n                Err(err) => {\n                    panic!(\"Couldn't load edits \\\"{}\\\": {}\", sim.edits_name, err);\n                }\n            }\n\n            (map, sim, rng)\n        } else if self.load.contains(\"/scenarios/\") {\n            info!(\"Seeding the simulation from scenario {}\", self.load);\n\n            let mut scenario: Scenario = abstio::must_read_object(self.load.clone(), timer);\n\n            let map = Map::load_synchronously(scenario.map_name.path(), timer);\n\n            for m in &self.scenario_modifiers {\n                scenario = m.apply(&map, scenario, &mut rng);\n            }\n\n            if opts.run_name == \"unnamed\" {\n                opts.run_name = scenario.scenario_name.clone();\n            }","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/sim/src/make/load.rs#L80-L116","documentation":"When the `load` value points at an edits file, load_synchronously parses it with abstutil and applies it to the map. If the edits file cannot be deserialized (corrupt JSON, wrong schema, missing file surfaced as an error), the loader panics because continuing with an un-edited map would silently produce wrong simulation results.","triggerScenarios":"Passing a path to a permanent edits file in `load` where abstutil::read fails: malformed JSON, edits produced by an older/newer schema version, wrong path, or the file failing must_apply_edits validation.","commonSituations":"Hand-edited or partially written edits JSON; edits saved from a different map version than the map being loaded; typos in the edits file path; repo data regenerated between versions.","solutions":["Regenerate or fix the edits JSON so it deserializes and matches the current map schema","Verify the path points to an existing edits file for THIS map (matching map version/name)","Load the map and apply edits interactively in the UI, then re-save the edits"],"exampleFix":"// check before loading\nif !abstutil::path_exists(&edits_path) {\n    eprintln!(\"missing edits file {}\", edits_path);\n} else {\n    flags.load_synchronously(&mut timer);\n}","handlingStrategy":"validation","validationCode":"if abstutil::path_exists(&edits_path) {\n    match abstutil::read_json::<PermanentEdits>(&edits_path) {\n        Ok(_) => flags.load_synchronously(&mut timer),\n        Err(e) => eprintln!(\"bad edits: {}\", e),\n    }\n}","typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(|| flags.load_synchronously(&mut timer));\nif result.is_err() { eprintln!(\"failed to load edits\"); }","preventionTips":["Re-save edits from the current map version before headless runs","Never hand-edit edits JSON; validate with JSON schema for the sim version"],"tags":["rust","panic","file-read-failed","json"],"backgroundTag":"file-read-failed","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"}