{"record":{"id":"cebfa05042e96f3d","repo":"stanfordnlp/CoreNLP","slug":"expected-left-paren","errorCode":null,"errorMessage":"Expected left paren!","messagePattern":"Expected left paren!","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/SemanticGraph.java","lineNumber":2017,"sourceCode":"          emptyIndex = 0;\n        }\n        return new Triple<>(word, index, emptyIndex);\n      }\n    }\n\n    private Integer getNextFreeIndex() {\n      int i = 0;\n      while (indexesUsed.containsKey(i))\n        i++;\n      return i;\n    }\n\n    private void readLeftBracket() {\n      // System.out.println(\"Read left.\");\n      readWhiteSpace();\n      char ch = read();\n      if (!isLeftBracket(ch))\n        throw new ParserException(\"Expected left paren!\");\n    }\n\n    private void readRightBracket() {\n      // System.out.println(\"Read right.\");\n      readWhiteSpace();\n      char ch = read();\n      if (!isRightBracket(ch))\n        throw new ParserException(\"Expected right paren!\");\n    }\n\n    private void readRelnSeparator() {\n      readWhiteSpace();\n      if (isRelnSeparator(peek()))\n        read();\n    }\n\n    private static boolean isLeftBracket(char ch) {\n      return ch == '[';","sourceCodeStart":1999,"sourceCodeEnd":2035,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/SemanticGraph.java#L1999-L2035","documentation":"SemanticGraph's text-format parser throws ParserException(\"Expected left paren!\") in readLeftBracket when the next non-whitespace character is not a recognized opening bracket ('(' / '['). It means the string being deserialized does not start a node entry as required by the SemanticGraph text format.","triggerScenarios":"SemanticGraph.valueOf(...) or the parser reading a string whose first token is not '(' or '[' — e.g. empty string, prose, a dependencies list without brackets, or output from a different format.","commonSituations":"Feeding toString(LIST) or human-readable output back into valueOf; truncation/corruption of a serialized graph; parsing a line with leading garbage or wrong locale whitespace characters.","solutions":["Feed the parser only strings produced by SemanticGraph.toString() (RECURSIVE format)","Trim/pre-validate the input starts with '(' or '[' before parsing","Check for file corruption or truncation in saved graph files","Catch ParserException around deserialization of untrusted input"],"exampleFix":"// before\nSemanticGraph sg = SemanticGraph.valueOf(userLine.trim());\n// after\nString s = userLine.trim();\nif (!s.startsWith(\"(\") && !s.startsWith(\"[\")) {\n  throw new IllegalArgumentException(\"Not a serialized SemanticGraph: \" + s);\n}\nSemanticGraph sg = SemanticGraph.valueOf(s);","handlingStrategy":"validation","validationCode":"String s = input.trim(); if (s.startsWith(\"(\") || s.startsWith(\"[\")) { SemanticGraph sg = SemanticGraph.valueOf(s); }","typeGuard":null,"tryCatchPattern":"try { sg = SemanticGraph.valueOf(s); } catch (ParserException e) { log.warn(\"Bad serialized graph: \" + s, e); }","preventionTips":["Only parse strings produced by SemanticGraph.toString()","Check bracket balance before parsing","Validate file integrity of stored graph dumps"],"tags":["java","nlp","parsing","malformed-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}