{"record":{"id":"8abb2153a31c7e27","repo":"stanfordnlp/CoreNLP","slug":"expected-right-paren","errorCode":null,"errorMessage":"Expected right paren!","messagePattern":"Expected right paren!","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/SemanticGraph.java","lineNumber":2025,"sourceCode":"      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 == '[';\n    }\n\n    private static boolean isRightBracket(char ch) {\n      return ch == ']';\n    }\n\n    private static boolean isRelnSeparator(char ch) {\n      return ch == '>';","sourceCodeStart":2007,"sourceCodeEnd":2043,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/SemanticGraph.java#L2007-L2043","documentation":"readRightBracket throws ParserException(\"Expected right paren!\") when, while parsing a serialized SemanticGraph, the character after a node/relation entry is not a closing bracket (')' or ']'). The serialized string is structurally incomplete or malformed.","triggerScenarios":"Deserializing a SemanticGraph from text where an entry is truncated mid-way, a bracket was stripped, or two graphs/lines were concatenated incorrectly.","commonSituations":"Line-based readers cutting a multi-line serialized graph in half; manual editing of .ser/text graph dumps; regex preprocessing that removed closing parens.","solutions":["Verify the serialized string is complete and balanced (count brackets) before parsing","Round-trip test: only parse strings produced by the same parser version's toString()","Read the entire serialized graph (not line-by-line) before handing it to the parser","Catch ParserException and log the offending string for diagnosis"],"exampleFix":"// before\nSemanticGraph sg = SemanticGraph.valueOf(line); // line truncated\n// after\nString full = fullGraphText.toString(); // accumulate complete text first\nif (full.chars().filter(c -> c == '(').count() != full.chars().filter(c -> c == ')').count()) {\n  throw new IllegalArgumentException(\"Unbalanced brackets\");\n}\nSemanticGraph sg = SemanticGraph.valueOf(full);","handlingStrategy":"validation","validationCode":"if (s.chars().filter(c -> c=='(').count() == s.chars().filter(c -> c==')').count() && s.trim().endsWith(\")\")) { SemanticGraph sg = SemanticGraph.valueOf(s); }","typeGuard":null,"tryCatchPattern":"try { sg = SemanticGraph.valueOf(s); } catch (ParserException e) { log.warn(\"Truncated graph text\", e); }","preventionTips":["Read the complete serialized graph before parsing (avoid line-by-line splitting)","Never hand-edit serialized graph text","Round-trip test serialization with the same parser version"],"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"}