{"record":{"id":"81779eb332d0f65c","repo":"t8y2/dbx","slug":"unknown-geometry-kind-kind","errorCode":null,"errorMessage":"unknown geometry kind: <kind>","messagePattern":"unknown geometry kind: <kind>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agents/common/src/main/java/com/dbx/agent/EwkbWktDecoder.java","lineNumber":534,"sourceCode":"                return \"MULTILINESTRING\" + suffix + \"(\" + joinRings(g.rings) + \")\";\n            case MULTIPOLYGON:\n                if (g.polygons == null || g.polygons.isEmpty()) {\n                    return \"MULTIPOLYGON\" + suffix + \" EMPTY\";\n                }\n                return \"MULTIPOLYGON\" + suffix + \"(\" + joinPolygons(g.polygons) + \")\";\n            case GEOMETRYCOLLECTION:\n                if (g.children == null || g.children.isEmpty()) {\n                    return \"GEOMETRYCOLLECTION\" + suffix + \" EMPTY\";\n                }\n                StringBuilder sb = new StringBuilder(\"GEOMETRYCOLLECTION\").append(suffix).append(\"(\");\n                for (int i = 0; i < g.children.size(); i++) {\n                    if (i > 0) sb.append(',');\n                    sb.append(geometryToWkt(g.children.get(i)));\n                }\n                sb.append(')');\n                return sb.toString();\n            default:\n                throw new IllegalStateException(\"unknown geometry kind: \" + g.kind);\n        }\n    }\n\n    private static String formatCoord(List<Double> coords) {\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < coords.size(); i++) {\n            if (i > 0) sb.append(' ');\n            sb.append(formatDouble(coords.get(i)));\n        }\n        return sb.toString();\n    }\n\n    private static String formatCoordSeq(List<List<Double>> points) {\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < points.size(); i++) {\n            if (i > 0) sb.append(',');\n            sb.append(formatCoord(points.get(i)));\n        }","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/EwkbWktDecoder.java#L516-L552","documentation":"EwkbWktDecoder.geometryToWkt() switches over the GeomKind enum and its default branch throws IllegalStateException(\"unknown geometry kind: ...\") as a defensive guard. It fires when a Geometry instance carries a GeomKind value the formatter has no case for — normally impossible for decoded EWKB, and indicates the enum was extended with a new kind without updating geometryToWkt, or a Geometry was constructed programmatically with an invalid kind.","triggerScenarios":"A GeomKind enum constant was added (e.g. a new geometry type like GEOMETRYCOLLECTION variant) but the switch in geometryToWkt was not updated; a Geometry object built outside decodeToWkt/decode paths has a null or out-of-range kind; kind is null and the switch has no null case.","commonSituations":"Upgrading the decoder library or adding new EWKB geometry types and hitting the guard while converting to WKT; custom code constructing Geometry records directly with a kind the formatter doesn't know.","solutions":["Add a case for the reported kind string to geometryToWkt's switch so the new geometry type is formatted.","If kind is null, trace where the Geometry was constructed and pass a valid GeomKind from the decoded EWKB type byte.","Check versions: ensure the EWKB decoding path and the WKT formatting switch come from the same build (rebuild after enum changes).","For valid-but-unformattable kinds, decode with a fallback that returns the hex representation instead of WKT."],"exampleFix":"// before\ndefault:\n    throw new IllegalStateException(\"unknown geometry kind: \" + g.kind);\n// after\ncase TRIANGLE:\n    sb.append(\"TRIANGLE(\")...;\n    return sb.toString();\ndefault:\n    throw new IllegalStateException(\"unknown geometry kind: \" + g.kind);","handlingStrategy":"try-catch","validationCode":"if (g == null || g.kind == null) { return fallbackHex; } // validate before formatting","typeGuard":"static boolean hasKnownKind(EwkbWktDecoder.Geometry g) {\n    return g != null && g.kind != null;\n}","tryCatchPattern":"try {\n    return geometryToWkt(g);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"unknown geometry kind\")) {\n        return originalHex; // fall back to raw EWKB hex\n    }\n    throw e;\n}","preventionTips":["When adding a GeomKind constant, update every switch over kind (compiler-exhaustive switch without default helps).","Only construct Geometry objects via the decoder, never by hand.","Round-trip test: decode EWKB then format WKT for every supported geometry type.","Keep decode and format code in the same module/version to avoid enum drift."],"tags":["geometry","ewkb","wkt","enum-coverage"],"backgroundTag":"unknown-enum-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}