{"record":{"id":"12367bd0d45fee8f","repo":"a-b-street/abstreet","slug":"at-has-weird-geom-along","errorCode":null,"errorMessage":"{} at {} has weird geom along {:?}: {}","messagePattern":"(.+?) at (.+?) has weird geom along (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sim/src/mechanics/car.rs","lineNumber":120,"sourceCode":"            let mut i = 0;\n            while leftover > Distance::ZERO {\n                if i == self.last_steps.len() {\n                    // The vehicle is gradually appearing from somewhere. That's fine, just return\n                    // a truncated body.\n                    break;\n                }\n                partly_on.push(self.last_steps[i]);\n                let len = self.last_steps[i].get_polyline(map).length();\n                let start = (len - leftover).max(Distance::ZERO);\n                let piece = self.last_steps[i]\n                    .get_polyline(map)\n                    .slice(start, len)\n                    .map(|(pl, _)| pl.into_points())\n                    .ok()\n                    .unwrap_or_else(Vec::new);\n                result = match PolyLine::append(piece, result) {\n                    Ok(pl) => pl,\n                    Err(err) => panic!(\n                        \"{} at {} has weird geom along {:?}: {}\",\n                        self.vehicle.id, now, self.last_steps, err\n                    ),\n                };\n                leftover -= len;\n                i += 1;\n            }\n\n            if result.len() < 2 {\n                // Vehicles spawning at a border start with their front at literally 0 distance.\n                // Usually by the time we first try to render, they've advanced at least a little.\n                // But sometimes there's a race when we try to immediately draw them.\n                if let Ok((pl, _)) = self\n                    .router\n                    .head()\n                    .get_polyline(map)\n                    .slice(Distance::ZERO, 2.0 * EPSILON_DIST)\n                {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/sim/src/mechanics/car.rs#L102-L138","documentation":"get_draw_car slices each past step's lane polyline to rebuild the car's rendered geometry and appends the pieces. If PolyLine::append fails (degenerate or disconnected geometry), rendering cannot continue and it panics with the vehicle id, time, step list, and the underlying polyline error.","triggerScenarios":"get_draw_car() during rendering when a sliced lane piece cannot be appended — usually zero-length or single-point polyline pieces produced after extreme map edits or degenerate lane geometry.","commonSituations":"Viewing a replay/simulation after edits that created degenerate lanes; cars whose last_steps span lanes with broken geometry; long replays crossing modified intersections.","solutions":["Inspect the printed vehicle id and last_steps; check the referenced lanes for degenerate geometry on the current map","Regenerate or fix the map geometry (avoid zero-length lanes) before replaying","Report as a rendering robustness bug; as a workaround, restart the sim on the unedited map"],"exampleFix":"// graceful alternative in caller code\nmatch car.get_draw_car(map, now) {\n    Ok(draw) => g.draw(...),\n    Err(_) => {} // skip rendering this car instead of crashing the frame\n}","handlingStrategy":"try-catch","validationCode":"// ensure the map has no degenerate lanes before replay\nfor l in map.all_lanes() {\n    assert!(l.length() > Distance::ZERO && l.center_pts.num_points() >= 2);\n}","typeGuard":null,"tryCatchPattern":"match std::panic::catch_unwind(|| car.get_draw_car(map, now)) {\n    Ok(draw) => g.draw(...),\n    Err(_) => {} // skip this car's draw\n}","preventionTips":["Keep map geometry valid (no zero-length lanes) before running/replaying sims","If it fires, capture the printed vehicle id and last_steps and file a bug with the map"],"tags":["rust","panic","internal-invariant-violation","rendering"],"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"}