{"record":{"id":"b212990e54d84757","repo":"OtterMind/Chat2DB","slug":"ewkb-contains-trailing-data","errorCode":null,"errorMessage":"EWKB contains trailing data","messagePattern":"EWKB contains trailing data","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-postgresql/src/main/java/ai/chat2db/plugin/postgresql/value/sub/PostgreSQLGeometryProcessor.java","lineNumber":167,"sourceCode":"            return null;\n        }\n        String candidate = value.trim();\n        if (candidate.startsWith(\"\\\\x\") || candidate.startsWith(\"\\\\X\")\n                || candidate.startsWith(\"0x\") || candidate.startsWith(\"0X\")) {\n            candidate = candidate.substring(2);\n        }\n        if (candidate.length() < 10 || candidate.length() % 2 != 0 || !HEX_PATTERN.matcher(candidate).matches()) {\n            return null;\n        }\n        return candidate;\n    }\n\n    private WkbHeader inspectEwkb(byte[] ewkb) {\n        // JTS repairs malformed rings and coordinate sequences, so validate the lossless subset first.\n        WkbCursor cursor = new WkbCursor(ewkb);\n        WkbHeader header = inspectGeometry(cursor, null, true, 0);\n        if (!cursor.isExhausted()) {\n            throw new IllegalArgumentException(\"EWKB contains trailing data\");\n        }\n        return header;\n    }\n\n    private WkbHeader inspectGeometry(WkbCursor cursor, Integer inheritedSrid, boolean root, int depth) {\n        if (depth > MAX_NESTED_DEPTH) {\n            throw new IllegalArgumentException(\"EWKB nesting is too deep\");\n        }\n        ByteOrder byteOrder = readByteOrder(cursor);\n        int typeWord = cursor.readInt(byteOrder);\n        if ((typeWord & EWKB_BBOX_FLAG) != 0) {\n            throw new IllegalArgumentException(\"EWKB bounding-box headers are not supported\");\n        }\n\n        int isoType = typeWord & EWKB_TYPE_MASK;\n        int dimensionCode = isoType / 1000;\n        int baseType = isoType % 1000;\n        if (dimensionCode > 3 || baseType < 1 || baseType > 7) {","sourceCodeStart":149,"sourceCodeEnd":185,"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#L149-L185","documentation":"Error \"EWKB contains trailing data\" thrown in OtterMind/Chat2DB.","triggerScenarios":"The EWKB parser finished the geometry before the buffer ended, indicating trailing garbage.","commonSituations":"See trigger scenarios.","solutions":["Ensure the EWKB value is not corrupted or concatenated with extra bytes; re-export the geometry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}