elastic/elasticsearch · error · IllegalArgumentException
only one z value is specified
Error message
only one z value is specified
What it means
Thrown by the 6-argument Rectangle constructor when exactly one of minZ/maxZ is NaN. The Z (altitude) dimension is optional for a Rectangle, but the library requires both Z bounds to be either present or absent — a half-specified Z range is treated as a programming error rather than a default.
Source
Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/Rectangle.java:78
this(minX, maxX, maxY, minY, Double.NaN, Double.NaN);
}
/**
* Constructs a bounding box by first validating the provided latitude and longitude coordinates
*/
public Rectangle(double minX, double maxX, double maxY, double minY, double minZ, double maxZ) {
this.minX = minX;
this.maxX = maxX;
this.minY = minY;
this.maxY = maxY;
this.minZ = minZ;
this.maxZ = maxZ;
empty = false;
if (maxY < minY) {
throw new IllegalArgumentException("max y cannot be less than min y");
}
if (Double.isNaN(minZ) != Double.isNaN(maxZ)) {
throw new IllegalArgumentException("only one z value is specified");
}
}
public double getMinY() {
return minY;
}
public double getMinX() {
return minX;
}
public double getMinZ() {
return minZ;
}
public double getMaxY() {
return maxY;
}View on GitHub (pinned to db6a809a66)
Solutions
- Pass Double.NaN for BOTH minZ and maxZ when the rectangle is 2D: `new Rectangle(minX, maxX, maxY, minY, Double.NaN, Double.NaN)`.
- If the rectangle is 3D, supply concrete numeric values for both minZ and maxZ.
- Audit upstream data: reject or normalize records where only one of the two altitude fields is present before they reach construction.
Example fix
// before new Rectangle(0, 10, 20, -20, Double.NaN, 50.0); // one z specified // after (2D) new Rectangle(0, 10, 20, -20, Double.NaN, Double.NaN); // after (3D) new Rectangle(0, 10, 20, -20, 0.0, 50.0);
Defensive patterns
Strategy: validation
Validate before calling
boolean zSpecified = !Double.isNaN(minZ) || !Double.isNaN(maxZ);
boolean zComplete = !Double.isNaN(minZ) && !Double.isNaN(maxZ);
if (zSpecified && !zComplete) throw new IllegalArgumentException("Specify both z bounds or neither");
new Rectangle(minX, maxX, maxY, minY, minZ, maxZ); Prevention
- Treat Z as a pair: always set both minZ and maxZ, or set both to Double.NaN.
- Centralize 2D-vs-3D rectangle construction in two named factory methods so the NaN pairing is enforced by the API.
- When ingesting data with optional altitude, normalize half-specified Z to fully unspecified (NaN) or to a 0-to-value range before construction.
When it happens
Trigger: Calling `new Rectangle(minX, maxX, maxY, minY, minZ, maxZ)` where `Double.isNaN(minZ) != Double.isNaN(maxZ)` — e.g. minZ=Double.NaN with maxZ=100.0, or minZ=0.0 with maxZ=Double.NaN.
Common situations: Mixing 2D and 3D data sources where some records carry altitude and others do not; defaulting one Z bound to NaN as a 'no bound' sentinel while leaving the other populated; copy-paste from a 2D-only code path that left one Z argument unset.
Related errors
- max y cannot be less than min y
- found Z value [
- max x cannot be less than min x
- invalid latitude
- invalid longitude
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/466d05f30872799d.
Report an issue: GitHub.