{"record":{"id":"7920c27e353887e3","repo":"databendlabs/databend","slug":"point-geometry","errorCode":null,"errorMessage":"point geometry","messagePattern":"point geometry","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/expression/src/geographic/aggregate.rs","lineNumber":93,"sourceCode":"        apply_geometry_overlay(geos, OverlayMode::SymDifference)\n    }\n    fn binary_compute(l_geo: Geometry<f64>, r_geo: Geometry<f64>) -> Result<Option<Geometry<f64>>> {\n        apply_binary_geometry_overlay(l_geo, r_geo, OverlayMode::SymDifference)\n    }\n}\n\npub struct CollectAggOp;\n\nimpl GeoAggOp for CollectAggOp {\n    fn compute(geos: Vec<Geometry<f64>>) -> Result<Option<Geometry<f64>>> {\n        if geos.is_empty() {\n            return Ok(None);\n        }\n\n        if geos.iter().all(|geo| matches!(geo, Geometry::Point(_))) {\n            let points: Vec<Point<f64>> = geos\n                .into_iter()\n                .map(|geo| geo.try_into().expect(\"point geometry\"))\n                .collect();\n            let multi_point = MultiPoint::from_iter(points);\n            return Ok(Some(Geometry::MultiPoint(multi_point)));\n        }\n        if geos\n            .iter()\n            .all(|geo| matches!(geo, Geometry::LineString(_)))\n        {\n            let lines: Vec<LineString<f64>> = geos\n                .into_iter()\n                .map(|geo| geo.try_into().expect(\"linestring geometry\"))\n                .collect();\n            let multi_line_string = MultiLineString::from_iter(lines);\n            return Ok(Some(Geometry::MultiLineString(multi_line_string)));\n        }\n        if geos.iter().all(|geo| matches!(geo, Geometry::Polygon(_))) {\n            let polygons: Vec<Polygon<f64>> = geos\n                .into_iter()","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/expression/src/geographic/aggregate.rs#L75-L111","documentation":"In the geographic aggregate `compute`, after verifying every geometry matches `Geometry::Point(_)`, each geometry is converted with `try_into::<Point<f64>>` and the result is unwrapped with `expect(\"point geometry\")`. The guard makes the conversion infallible in theory; the panic fires only if the Point→point conversion impl itself fails, indicating a bug in the TryFrom implementation or a corrupted geometry value. It is an internal invariant assertion, not user-facing input validation.","triggerScenarios":"Running a geographic aggregate (e.g. ST_ASTEXT-style aggregation of points) over values where the guarded `Geometry::Point(_)` branch executes but the `TryFrom<Geometry> for Point<f64>` conversion returns Err — e.g. a Point carrying invalid/empty coordinate data the converter rejects.","commonSituations":"Feeding degenerate or NaN-coordinate points into geometry aggregation; a geo crate version change altering conversion semantics; corrupted geometry values from deserialization.","solutions":["Inspect the geometries feeding the aggregate for degenerate coordinates (NaN, empty) that the Point TryFrom impl rejects.","Verify geo crate version compatibility of the `TryFrom<Geometry> for Point<f64>` impl.","If a legitimate non-convertible case exists, replace the expect with error propagation (`?` into the surrounding `Ok` result)."],"exampleFix":"// before\n.map(|geo| geo.try_into().expect(\"point geometry\"))\n// after\n.map(|geo| geo.try_into().map_err(|e| ErrorCode::BadArguments(format!(\"point geometry: {e}\"))))\n.collect::<Result<Vec<_>, _>>()?;","handlingStrategy":"validation","validationCode":"// caller-side check before aggregating:\nlet all_valid_points = geos.iter().all(|g| matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()));","typeGuard":"fn is_finite_point(g: &Geometry) -> bool { matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()) }","tryCatchPattern":"// panics are not catchable in stable Rust without catch_unwind:\nlet result = std::panic::catch_unwind(|| aggregate_points(geos.clone()));","preventionTips":["Sanitize geometry inputs for NaN/empty coordinates before aggregation.","Pin and test the geo crate version used by the library.","Treat this panic as a bug report signal — file it with the offending geometry values."],"tags":["rust","geospatial","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}