{"record":{"id":"75f7aeab8a970c08","repo":"elastic/elasticsearch","slug":"expected-but-found-75f7ae","errorCode":null,"errorMessage":"expected , but found: {}","messagePattern":"expected , but found: (.+?)","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java","lineNumber":765,"sourceCode":"        final String next = nextWord(stream);\n        if (next.equals(EMPTY) || next.equals(LPAREN)) {\n            return next;\n        }\n        throw new ParseException(\"expected \" + EMPTY + \" or \" + LPAREN + \" but found: \" + tokenString(stream), stream.lineno());\n    }\n\n    static String nextCloser(StreamTokenizer stream) throws IOException, ParseException {\n        if (nextWord(stream).equals(RPAREN)) {\n            return RPAREN;\n        }\n        throw new ParseException(\"expected \" + RPAREN + \" but found: \" + tokenString(stream), stream.lineno());\n    }\n\n    static String nextComma(StreamTokenizer stream) throws IOException, ParseException {\n        if (nextWord(stream).equals(COMMA)) {\n            return COMMA;\n        }\n        throw new ParseException(\"expected \" + COMMA + \" but found: \" + tokenString(stream), stream.lineno());\n    }\n\n    static String nextOpener(StreamTokenizer stream) throws IOException, ParseException {\n        if (nextWord(stream).equals(LPAREN)) {\n            return LPAREN;\n        }\n        throw new ParseException(\"expected \" + LPAREN + \" but found: \" + tokenString(stream), stream.lineno());\n    }\n\n    static String nextCloserOrComma(StreamTokenizer stream) throws IOException, ParseException {\n        String token = nextWord(stream);\n        if (token.equals(COMMA) || token.equals(RPAREN)) {\n            return token;\n        }\n        throw new ParseException(\"expected \" + COMMA + \" or \" + RPAREN + \" but found: \" + tokenString(stream), stream.lineno());\n    }\n\n    private static String getWKTName(Geometry geometry) {","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/geo/src/main/java/org/elasticsearch/geometry/utils/WellKnownText.java#L747-L783","documentation":"Thrown by WellKnownText.nextComma when the token at the current position is not ','. This helper asserts a comma separator, used between elements in multi-component structures.","triggerScenarios":"WKT where a comma is expected between components but is missing or replaced. This helper is used in specific contexts requiring exactly a comma; if the structure needs comma-or-closer, the parser uses nextCloserOrComma instead.","commonSituations":"Malformed multi-part WKT where a separator is missing; tokenizer positioned wrong due to a prior error; hand-authored WKT with spaces instead of commas between sub-elements where nextComma is called.","solutions":["Insert the missing ',' separator at the position indicated by stream.lineno().","Verify the WKT structure matches the grammar for the geometry type (e.g., ring vertices separated by commas, rings separated by commas)."],"exampleFix":"// before: missing comma between vertices in a ring\nGeometry g = WellKnownText.fromWKT(\"LINESTRING (0 0 1 1)\");\n\n// after: comma-separated vertices\nGeometry g = WellKnownText.fromWKT(\"LINESTRING (0 0, 1 1)\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Geometry g = WellKnownText.fromWKT(wkt);\n} catch (java.text.ParseException e) {\n    if (e.getMessage().contains(\"expected ,\")) {\n        // missing comma separator at the reported line\n    }\n    throw e;\n}","preventionTips":["Insert commas between list elements per the geometry grammar.","Validate separator placement before parsing."],"tags":["geo","wkt","parsing","elasticsearch","geometry"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}