{"record":{"id":"e1fa099e45684509","repo":"stanfordnlp/CoreNLP","slug":"error-in-ssurgeonedit-parseeditline-invalid-numbe","errorCode":null,"errorMessage":"Error in SsurgeonEdit.parseEditLine: invalid number of arguments","messagePattern":"Error in SsurgeonEdit\\.parseEditLine: invalid number of arguments","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":598,"sourceCode":"          Class<? extends CoreAnnotation<?>> annotation = AnnotationLookup.toCoreKey(key);\n          if (annotation == null) {\n            throw new SsurgeonParseException(\"Parsing Ssurgeon args: unknown flag \" + argsKey);\n          }\n          argsBox.annotations.put(key, argsValue);\n      }\n    }\n    return argsBox;\n  }\n\n  /**\n   * Given a string entry, converts it into a SsurgeonEdit object.\n   */\n  public static SsurgeonEdit parseEditLine(String editLine, Map<String, String> attributeArgs, Language language) {\n    try {\n      // Extract the operation name first\n      final String[] tuples1 = editLine.split(\"\\\\s+\", 2);\n      if (tuples1.length < 1) {\n        throw new SsurgeonParseException(\"Error in SsurgeonEdit.parseEditLine: invalid number of arguments\");\n      }\n      final String command = tuples1[0];\n\n      if (command.equalsIgnoreCase(SetRoots.LABEL)) {\n        String[] names = tuples1[1].split(\"\\\\s+\");\n        List<String> newRoots = Arrays.asList(names);\n        return new SetRoots(newRoots);\n      } else if (command.equalsIgnoreCase(KillNonRootedNodes.LABEL)) {\n        return new KillNonRootedNodes();\n      }\n\n      // Parse the arguments based upon the type of command to execute.\n      final SsurgeonArgs argsBox = parseArgsBox(tuples1.length == 1 ? \"\" : tuples1[1], attributeArgs);\n\n      if (command.equalsIgnoreCase(AddDep.LABEL)) {\n        if (argsBox.reln == null) {\n          throw new SsurgeonParseException(\"Relation not specified for AddDep\");\n        }","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L580-L616","documentation":"SsurgeonEdit.parseEditLine first splits the edit line on whitespace and expects at least the operation name. SsurgeonParseException('invalid number of arguments') is thrown when the line splits to nothing usable, i.e. an empty or blank edit line was handed to the parser.","triggerScenarios":"Calling SsurgeonEdit.parseEditLine (or Ssurgeon processRuleTexts / fromString) with an empty string or whitespace-only line, so editLine.split(\"\\\\s+\", 2) yields fewer than 1 meaningful element.","commonSituations":"Rule files with blank lines not filtered before parsing; a resources file read producing empty entries; programmatically building rules with an empty string due to an upstream concatenation bug.","solutions":["Skip blank lines when feeding lines to parseEditLine (check line.trim().isEmpty() first).","Verify the rule resource file has no empty rule entries between separators.","Catch SsurgeonParseException and log which rule line number failed so the empty one can be fixed."],"exampleFix":"// before\nSsurgeonEdit.parseEditLine(line, attributeArgs, language);\n// after\nif (line.trim().isEmpty()) continue;\nSsurgeonEdit.parseEditLine(line, attributeArgs, language);","handlingStrategy":"validation","validationCode":"for (String line : ruleText.split(\"\\n\")) {\n  if (!line.trim().isEmpty()) SsurgeonEdit.parseEditLine(line.trim(), Map.of(), language);\n}","typeGuard":null,"tryCatchPattern":"try { parseLine(line); } catch (SsurgeonParseException e) { if (e.getMessage().contains(\"invalid number of arguments\")) log.warn(\"Skipping blank rule line\"); }","preventionTips":["Filter blank lines before parsing rule text","Trim lines read from resource files","Validate rule files at startup, not at match time"],"tags":["parsing","ssurgeon","empty-input"],"backgroundTag":"missing-required-argument","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"}