{"record":{"id":"676c6620e24a2926","repo":"elastic/elasticsearch","slug":"invalid-latitude","errorCode":null,"errorMessage":"invalid latitude ","messagePattern":"invalid latitude ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/geo/src/main/java/org/elasticsearch/geometry/utils/GeographyValidator.java","lineNumber":71,"sourceCode":"     */\n    private static final double MAX_LAT_INCL = 90.0D;\n\n    private final boolean ignoreZValue;\n\n    protected GeographyValidator(boolean ignoreZValue) {\n        this.ignoreZValue = ignoreZValue;\n    }\n\n    public static GeometryValidator instance(boolean ignoreZValue) {\n        return ignoreZValue ? TRUE : FALSE;\n    }\n\n    /**\n     * validates latitude value is within standard +/-90 coordinate bounds\n     */\n    protected void checkLatitude(double latitude) {\n        if (Double.isNaN(latitude) || latitude < MIN_LAT_INCL || latitude > MAX_LAT_INCL) {\n            throw new IllegalArgumentException(\n                \"invalid latitude \" + latitude + \"; must be between \" + MIN_LAT_INCL + \" and \" + MAX_LAT_INCL\n            );\n        }\n    }\n\n    /**\n     * validates longitude value is within standard +/-180 coordinate bounds\n     */\n    protected void checkLongitude(double longitude) {\n        if (Double.isNaN(longitude) || longitude < MIN_LON_INCL || longitude > MAX_LON_INCL) {\n            throw new IllegalArgumentException(\n                \"invalid longitude \" + longitude + \"; must be between \" + MIN_LON_INCL + \" and \" + MAX_LON_INCL\n            );\n        }\n    }\n\n    protected void checkAltitude(double zValue) {\n        if (ignoreZValue == false && Double.isNaN(zValue) == false) {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/geo/src/main/java/org/elasticsearch/geometry/utils/GeographyValidator.java#L53-L89","documentation":"Thrown by GeographyValidator.checkLatitude when a latitude value is NaN or falls outside the inclusive range [-90.0, 90.0]. Geographic coordinates require latitude to stay within the pole-to-pole range; anything else is treated as corrupt input. The bounds are inclusive on both ends.","triggerScenarios":"Any path that calls checkLatitude directly or indirectly (validateCoordinate, validate(Geometry) on a geometry containing points, etc.) with a y-value that is NaN, less than -90.0, or greater than 90.0.","commonSituations":"Swapped lat/lon columns in source data (longitude 120 sent as latitude); unbounded numeric inputs not clamped before validation; null/missing values converted to NaN; projections or computations that overflow the valid range.","solutions":["Confirm the value is latitude and is in [-90, 90]; clamp or reject out-of-range values upstream.","Check for swapped lat/lon — if the failing value looks like a longitude (>90), the columns are reversed.","Filter NaN before validation if missing data should be skipped rather than rejected."],"exampleFix":"// before\nGeographyValidator.instance(true).validateCoordinate(120.0, 130.0, Double.NaN); // lat=130 invalid\n\n// after\nGeographyValidator.instance(true).validateCoordinate(130.0, 120.0, Double.NaN); // lon=130, lat=120 -> still bad\nGeographyValidator.instance(true).validateCoordinate(130.0, 45.0, Double.NaN); // correct: lon=130, lat=45","handlingStrategy":"validation","validationCode":"if (Double.isNaN(lat) || lat < -90.0 || lat > 90.0) {\n    throw new IllegalArgumentException(\"latitude out of range: \" + lat);\n}\nGeographyValidator.instance(ignoreZ).validateCoordinate(lon, lat, z);","typeGuard":"static boolean isValidLatitude(double lat) {\n    return !Double.isNaN(lat) && lat >= -90.0 && lat <= 90.0;\n}","tryCatchPattern":null,"preventionTips":["Check for swapped lat/lon — a value > 90 in the latitude slot usually means columns are reversed.","Clamp or reject out-of-range latitudes at ingestion.","Filter NaN latitudes if missing data should be skipped."],"tags":["geometry","validation","geographic","latitude","coordinate-bounds","libs-geo"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}