{"record":{"id":"4acafde29ebf4aeb","repo":"a-b-street/abstreet","slug":"causes-illegal-entrance-into-a-zone-at","errorCode":null,"errorMessage":"{} causes illegal entrance into a zone at {}","messagePattern":"(.+?) causes illegal entrance into a zone at (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"map_model/src/pathfind/v1.rs","lineNumber":837,"sourceCode":"            if map\n                .get_parent(t.src)\n                .access_restrictions\n                .allow_through_traffic\n                .contains(req.constraints)\n                && !map\n                    .get_parent(t.dst)\n                    .access_restrictions\n                    .allow_through_traffic\n                    .contains(req.constraints)\n            {\n                // Entering our destination zone is fine\n                let into_zone = map.get_parent(t.dst).get_zone(map);\n                if into_zone != z1 && into_zone != z2 {\n                    // TODO There are lots of false positive here that occur when part of the graph\n                    // is separated from the rest by access-restricted roads. Could maybe detect\n                    // that here, or ideally even extend the zone at map construction time (or edit\n                    // time) when that happens.\n                    panic!(\"{} causes illegal entrance into a zone at {}\", req, t);\n                }\n            }\n        }\n    }\n}\n","sourceCodeStart":819,"sourceCodeEnd":843,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_model/src/pathfind/v1.rs#L819-L843","documentation":"validate_zones enforces access-restriction zones: a path may not cut through a road that allows through traffic for the request's mode and then enter a restricted zone that is neither the origin's nor destination's zone. When a turn in the produced path crosses into such a zone, Path::new panics. The source notes known false positives when part of the graph is separated from the rest by access-restricted roads.","triggerScenarios":"Path::new called on a path whose turn enters a zone with access restrictions after leaving an unrestricted road, where the entered zone differs from both the start and end zones — common after map edits that add access restrictions (e.g. private roads, gates).","commonSituations":"Hit when editing access restrictions in the map editor or importing OSM access tags; the code comment acknowledges false positives when a graph region is only reachable through restricted roads.","solutions":["Check whether the path legitimately must enter the restricted zone because the graph is disconnected otherwise — if so, it's a known false positive; extend the zone at map construction/edit time instead","Adjust the access restrictions on the edited roads so the zone partition matches reality","Fix the pathfind cost function to properly penalize/forbid restricted-zone crossings for the mode","Report upstream if it reproduces on stock maps, including the PathRequest and turn ID"],"exampleFix":"// before\npanic!(\"{} causes illegal entrance into a zone at {}\", req, t);\n// after\nwarn!(\"{} crosses into restricted zone at {}; allowing (known false positive)\", req, t);\nreturn Ok(path); // or extend the zone during map construction","handlingStrategy":"validation","validationCode":"fn enters_foreign_restricted_zone(map: &Map, steps: &[PathStep], req: &PathRequest) -> bool {\n    let z1 = map.get_parent(req.start.lane()).get_zone(map);\n    let z2 = map.get_parent(req.end.lane()).get_zone(map);\n    steps.iter().any(|s| match s {\n        PathStep::Turn(t) | PathStep::ContraflowTurn(t) => {\n            let z = map.get_parent(t.dst).get_zone(map);\n            z != z1 && z != z2\n        }\n        _ => false,\n    })\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding access restrictions, extend zones at map construction/edit time so disconnected regions are handled","Test paths in areas partitioned by restricted roads to detect false positives","Adjust or remove restrictions that fully seal off a graph region"],"tags":["rust","pathfinding","access-restrictions","panic"],"backgroundTag":"internal-invariant-violation","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"}