{"record":{"id":"24c79b8f6cd0e8ce","repo":"elastic/elasticsearch","slug":"max-y-cannot-be-less-than-min-y-24c79b","errorCode":null,"errorMessage":"max y cannot be less than min y","messagePattern":"max y cannot be less than min y","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"libs/geo/src/main/java/org/elasticsearch/geometry/utils/GeometryValidator.java","lineNumber":42,"sourceCode":"    void validate(Geometry geometry);\n\n    /**\n     * Validates a single coordinate and throws IllegalArgumentException if it is not valid.\n     * Default implementation is a no-op.\n     */\n    default void validateCoordinate(double x, double y, double z) {}\n\n    /**\n     * Validates the ordinate ordering of a rectangle/envelope, throwing IllegalArgumentException if the\n     * envelope is invalid. The default implementation only checks that maxY is not less than minY, since that\n     * is always invalid, regardless of CRS. It deliberately does not check x-ordinate ordering: geographic\n     * coordinates allow minX to legitimately exceed maxX, to represent an envelope that crosses the\n     * antimeridian, so only implementations for CRSes without that concept (e.g. {@link CartesianValidator})\n     * need to additionally check that maxX is not less than minX.\n     */\n    default void validateBBox(double minX, double maxX, double maxY, double minY) {\n        if (maxY < minY) {\n            throw new IllegalArgumentException(\"max y cannot be less than min y\");\n        }\n    }\n\n}\n","sourceCodeStart":24,"sourceCodeEnd":47,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/geo/src/main/java/org/elasticsearch/geometry/utils/GeometryValidator.java#L24-L47","documentation":"Thrown by the default GeometryValidator.validateBBox method when maxY < minY. This default applies to any CRS because an inverted y-range is never geometrically valid. The default deliberately does NOT check x-ordering, because geographic coordinates legitimately allow minX > maxX (antimeridian crossing); only CartesianValidator overrides to add the x-check.","triggerScenarios":"Calling `validator.validateBBox(minX, maxX, maxY, minY)` on any GeometryValidator (default or override that calls super) where maxY < minY. The default implementation runs in GeographyValidator, which delegates to this default for bbox.","commonSituations":"Argument-order mistakes (the signature passes maxY before minY); inverted bounding boxes from upstream computations; user-supplied bbox parameters with swapped corners.","solutions":["Pass arguments in (minX, maxX, maxY, minY) order with maxY >= minY.","Normalize the bounds before validating: `double lo = Math.min(y1, y2); double hi = Math.max(y1, y2);`","If the input truly represents an inverted envelope (rare for y), no Rectangle/bbox can express it — restructure."],"exampleFix":"// before\nvalidator.validateBBox(0, 10, -20, 20); // maxY(-20) < minY(20)\n\n// after\nvalidator.validateBBox(0, 10, 20, -20); // maxY(20) >= minY(-20)","handlingStrategy":"validation","validationCode":"double lo = Math.min(y1, y2);\ndouble hi = Math.max(y1, y2);\nvalidator.validateBBox(minX, maxX, hi, lo);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize y-ordinate pairs with Math.min/Math.max before validateBBox.","Pass arguments in (minX, maxX, maxY, minY) order — maxY precedes minY.","Wrap bbox validation in a helper that accepts unordered corners."],"tags":["geometry","validation","bounding-box","default-impl","coordinate-bounds","libs-geo"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}