OtterMind/Chat2DB · error · IllegalArgumentException
EWKB nesting is too deep
Error message
EWKB nesting is too deep
What it means
Error "EWKB nesting is too deep" thrown in OtterMind/Chat2DB.
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-postgresql/src/main/java/ai/chat2db/plugin/postgresql/value/sub/PostgreSQLGeometryProcessor.java:174
if (candidate.length() < 10 || candidate.length() % 2 != 0 || !HEX_PATTERN.matcher(candidate).matches()) {
return null;
}
return candidate;
}
private WkbHeader inspectEwkb(byte[] ewkb) {
// JTS repairs malformed rings and coordinate sequences, so validate the lossless subset first.
WkbCursor cursor = new WkbCursor(ewkb);
WkbHeader header = inspectGeometry(cursor, null, true, 0);
if (!cursor.isExhausted()) {
throw new IllegalArgumentException("EWKB contains trailing data");
}
return header;
}
private WkbHeader inspectGeometry(WkbCursor cursor, Integer inheritedSrid, boolean root, int depth) {
if (depth > MAX_NESTED_DEPTH) {
throw new IllegalArgumentException("EWKB nesting is too deep");
}
ByteOrder byteOrder = readByteOrder(cursor);
int typeWord = cursor.readInt(byteOrder);
if ((typeWord & EWKB_BBOX_FLAG) != 0) {
throw new IllegalArgumentException("EWKB bounding-box headers are not supported");
}
int isoType = typeWord & EWKB_TYPE_MASK;
int dimensionCode = isoType / 1000;
int baseType = isoType % 1000;
if (dimensionCode > 3 || baseType < 1 || baseType > 7) {
throw new IllegalArgumentException("Unsupported EWKB geometry type");
}
boolean hasZ = (typeWord & EWKB_Z_FLAG) != 0 || dimensionCode == 1 || dimensionCode == 3;
boolean hasMeasure = (typeWord & EWKB_M_FLAG) != 0 || dimensionCode == 2 || dimensionCode == 3;
boolean hasSrid = (typeWord & EWKB_SRID_FLAG) != 0;
Integer srid = hasSrid ? cursor.readInt(byteOrder) : null;View on GitHub (pinned to 5ee1e990e7)
Solutions
- Reduce the nesting depth of the geometry collection, or flatten the geometry before storing.
When it happens
Trigger: An EWKB geometry collection was nested deeper than the parser's limit.
Common situations: See trigger scenarios.
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/a990ce257cf2f276.
Report an issue: GitHub.