OtterMind/Chat2DB · error · IllegalArgumentException

EWKB contains trailing data

Error message

EWKB contains trailing data

What it means

Error "EWKB contains trailing data" 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:167

            return null;
        }
        String candidate = value.trim();
        if (candidate.startsWith("\\x") || candidate.startsWith("\\X")
                || candidate.startsWith("0x") || candidate.startsWith("0X")) {
            candidate = candidate.substring(2);
        }
        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) {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure the EWKB value is not corrupted or concatenated with extra bytes; re-export the geometry.

When it happens

Trigger: The EWKB parser finished the geometry before the buffer ended, indicating trailing garbage.

Common situations: See trigger scenarios.


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/b212990e54d84757. Report an issue: GitHub.