{"record":{"id":"10f154f67a9bab50","repo":"OtterMind/Chat2DB","slug":"ewkb-collection-contains-mixed-coordinate-dimensio","errorCode":null,"errorMessage":"EWKB collection contains mixed coordinate dimensions","messagePattern":"EWKB collection contains mixed coordinate dimensions","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"info","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-postgresql/src/main/java/ai/chat2db/plugin/postgresql/value/sub/PostgreSQLGeometryProcessor.java","lineNumber":286,"sourceCode":"            coordinate[i] = cursor.readDouble(byteOrder);\n            if (!Double.isFinite(coordinate[i])) {\n                throw new IllegalArgumentException(\"EWKB coordinate is not finite\");\n            }\n        }\n        return coordinate;\n    }\n\n    private void inspectChildren(WkbCursor cursor, ByteOrder byteOrder, WkbHeader parent,\n                                 Integer inheritedSrid, int expectedType, int depth) {\n        int childCount = readCount(cursor, byteOrder);\n        Integer effectiveSrid = parent.srid() != null ? parent.srid() : inheritedSrid;\n        for (int i = 0; i < childCount; i++) {\n            WkbHeader child = inspectGeometry(cursor, effectiveSrid, false, depth + 1);\n            if (expectedType != 0 && child.baseType() != expectedType) {\n                throw new IllegalArgumentException(\"EWKB collection contains an unexpected geometry type\");\n            }\n            if (child.hasZ() != parent.hasZ() || child.hasMeasure() != parent.hasMeasure()) {\n                throw new IllegalArgumentException(\"EWKB collection contains mixed coordinate dimensions\");\n            }\n        }\n    }\n\n    private int readCount(WkbCursor cursor, ByteOrder byteOrder) {\n        int count = cursor.readInt(byteOrder);\n        if (count < 0) {\n            throw new IllegalArgumentException(\"EWKB contains a negative element count\");\n        }\n        return count;\n    }\n\n    private ByteOrder readByteOrder(WkbCursor cursor) {\n        int byteOrder = cursor.readUnsignedByte();\n        if (byteOrder == 0) {\n            return ByteOrder.BIG_ENDIAN;\n        }\n        if (byteOrder == 1) {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-postgresql/src/main/java/ai/chat2db/plugin/postgresql/value/sub/PostgreSQLGeometryProcessor.java#L268-L304","documentation":"Thrown by PostgreSQLGeometryProcessor.inspectChildren when a child geometry's coordinate dimension flags (hasZ, hasMeasure) differ from the parent collection's. All children in a collection must share the same Z and M dimensionality as the parent. The check at line 285 compares child.hasZ() to parent.hasZ() and child.hasMeasure() to parent.hasMeasure(). The exception is caught by convertJDBCValueByType at line 80 and the raw hex value is returned gracefully.","triggerScenarios":"Converting a collection geometry (baseType 4-7) where one or more children declare different Z or M dimension flags than the parent. For example, a MULTILINESTRING with hasZ=true containing a child LINESTRING with hasZ=false.","commonSituations":"Collections assembled from geometries created with different dimension settings; data produced by a tool that does not enforce consistent dimensionality across collection members; EWKB from mixed PostGIS versions.","solutions":["No action required in production — convertJDBCValueByType catches this and returns the raw hex value","Rebuild the collection so all children share the parent's Z and M flags","Use ST_Force3D or ST_Force2D in PostgreSQL to normalize all children to the same dimensionality"],"exampleFix":"-- before: MULTILINESTRING mixing 2D and 3D children (invalid)\n-- after: consistent Z across all children\nSELECT ST_GeomFromEWKT('MULTILINESTRING((0 0 1, 1 1 2), (2 2 3, 3 3 4))');","handlingStrategy":"try-catch","validationCode":"// Already caught in convertJDBCValueByType. For data-level validation:\n// Use ST_Force3D / ST_Force2D to normalize all children to consistent dimensions.\n// SELECT ST_AsEWKT(ST_Force3D(geom)) FROM my_table;","typeGuard":null,"tryCatchPattern":"try {\n    inspectChildren(cursor, byteOrder, header, srid, expectedType, depth);\n} catch (IllegalArgumentException e) {\n    log.debug(\"EWKB mixed dimensions\", e);\n    return value;\n}","preventionTips":["Normalize all collection children to the same Z/M dimensionality before storing","Use ST_Force3D or ST_Force2D to enforce consistent dimensions","Validate dimension consistency with ST_CoordDim on each child"],"tags":["postgresql","ewkb","geometry","collection","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}