elastic/elasticsearch · error · IllegalArgumentException
Empty POINT cannot be represented in WKB
Error message
Empty POINT cannot be represented in WKB
What it means
writeWKBPoint (line 274) is the WKT-to-WKB direct converter for the POINT type. After reading the type word, it consumes the next token via nextEmptyOrOpen (line 281); if that token is 'EMPTY', it throws IllegalArgumentException because, per the toWKB rule (error 562), WKB cannot encode an empty Point. This is the WKT-input variant of the same format limitation.
Source
Thrown at libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownBinary.java:282
case "multilinestring" -> writeWKBMultiLineString(stream, out, scratch, explicitZ, validator);
case "polygon" -> writeWKBPolygon(stream, out, scratch, coerce, explicitZ, validator);
case "multipolygon" -> writeWKBMultiPolygon(stream, out, scratch, coerce, explicitZ, validator);
case "geometrycollection" -> writeWKBGeometryCollection(stream, out, scratch, coerce, depth, explicitZ, validator);
case "circle" -> writeWKBCircle(stream, out, scratch, explicitZ, validator);
case "bbox" -> writeWKBBBox(stream, out, scratch, explicitZ, validator);
default -> throw new ParseException("Unknown geometry type: " + type, stream.lineno());
}
}
private static void writeWKBPoint(
StreamTokenizer stream,
ByteArrayOutputStream out,
ByteBuffer scratch,
boolean explicitZ,
GeometryValidator validator
) throws IOException, ParseException {
if (WellKnownText.nextEmptyOrOpen(stream).equals(WellKnownText.EMPTY)) {
throw new IllegalArgumentException("Empty POINT cannot be represented in WKB");
}
double x = WellKnownText.nextNumber(stream);
double y = WellKnownText.nextNumber(stream);
double z = Double.NaN;
if (WellKnownText.isNumberNext(stream)) {
z = WellKnownText.nextNumber(stream);
}
WellKnownText.nextCloser(stream);
WellKnownText.checkZorMAttribute(explicitZ, Double.isNaN(z) == false);
validator.validateCoordinate(x, y, z);
boolean hasZ = Double.isNaN(z) == false;
writeInt(out, scratch, hasZ ? 1001 : 1);
writeDouble(out, scratch, x);
writeDouble(out, scratch, y);
if (hasZ) {
writeDouble(out, scratch, z);
}
}View on GitHub (pinned to db6a809a66)
Solutions
- Detect and skip 'POINT EMPTY' (case-insensitive, trimmed) before calling fromWKT, treating it as absent data.
- Normalize empty points to a concrete coordinate or to a null/absent document upstream.
- If you must preserve emptiness, use a format that supports it (WKT for storage, or a sentinel schema field) rather than WKB.
Example fix
// before
byte[] wkb = WellKnownBinary.fromWKT("POINT EMPTY", ByteOrder.LITTLE_ENDIAN, false); // throws
// after
String wkt = wktInput.trim();
if (wkt.equalsIgnoreCase("POINT EMPTY")) {
return null; // or handle absence
}
byte[] wkb = WellKnownBinary.fromWKT(wkt, ByteOrder.LITTLE_ENDIAN, false); Defensive patterns
Strategy: validation
Validate before calling
boolean isPointEmpty(String wkt) {
return wkt.trim().equalsIgnoreCase("POINT EMPTY");
} Type guard
// lexical guard — WKT has no object yet
static boolean isEmptyPointWkt(String wkt) {
return wkt.trim().equalsIgnoreCase("POINT EMPTY");
} Try / catch
try {
return WellKnownBinary.fromWKT(wkt, bo, coerce, v);
} catch (IllegalArgumentException e) {
if (wkt.trim().equalsIgnoreCase("POINT EMPTY")) return null;
throw e;
} Prevention
- Normalize 'POINT EMPTY' to absent/null at ingest, before WKB conversion.
- Use WKT (not WKB) as the on-disk format if empty points must be preserved.
- Apply a shared empty-WKT filter for POINT/CIRCLE/BBOX empties.
When it happens
Trigger: Calling WellKnownBinary.fromWKT("POINT EMPTY", byteOrder, coerce[, validator]). The exact trigger is the literal WKT token 'POINT' followed by 'EMPTY' (case-insensitive type, but EMPTY keyword recognized by nextEmptyOrOpen).
Common situations: Indexing optional-location fields where the source represents absence as 'POINT EMPTY' in WKT. Round-tripping data that used WKT's empty-point syntax. Ingest pipelines that pass through user-supplied WKT without normalizing empty points.
Related errors
- Empty
- Empty CIRCLE cannot be represented in WKB
- Empty ENVELOPE cannot be represented in WKB
- Unknown geometry type:
- holes must have the same number of dimensions as the polygon
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/5a6a7b603e97f9ac.
Report an issue: GitHub.