{"record":{"id":"46f00417929f2902","repo":"stanfordnlp/CoreNLP","slug":"relation-not-specified-for-adddep","errorCode":null,"errorMessage":"Relation not specified for AddDep","messagePattern":"Relation not specified for AddDep","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java","lineNumber":615,"sourceCode":"      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        }\n        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);\n        return new AddDep(argsBox.govNodeName, reln, argsBox.annotations, argsBox.position);\n      } else if (command.equalsIgnoreCase(AddNode.LABEL)) {\n        return AddNode.createAddNode(argsBox.nodeString, argsBox.name);\n      } else if (command.equalsIgnoreCase(AddEdge.LABEL)) {\n        if (argsBox.reln == null) {\n          throw new SsurgeonParseException(\"Relation not specified for AddEdge\");\n        }\n        GrammaticalRelation reln = GrammaticalRelation.valueOf(language, argsBox.reln);\n        return new AddEdge(argsBox.govNodeName, argsBox.dep, reln, argsBox.weight);\n      } else if (command.equalsIgnoreCase(ReattachNamedEdge.LABEL)) {\n          return new ReattachNamedEdge(argsBox.edge, argsBox.govNodeName, argsBox.dep);\n      } else if (command.equalsIgnoreCase(DeleteGraphFromNode.LABEL)) {\n        if (argsBox.nodes.size() != 1) {\n          throw new SsurgeonParseException(\"Cannot make a DeleteGraphFromNode out of \" + argsBox.nodes.size() + \" nodes\");\n        }\n        return new DeleteGraphFromNode(argsBox.nodes.get(0));","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/Ssurgeon.java#L597-L633","documentation":"When parsing an AddDep edit, parseEditLine requires the -reln argument giving the GrammaticalRelation for the new dependent edge. If argsBox.reln is null (no -reln flag was supplied), SsurgeonParseException('Relation not specified for AddDep') is thrown.","triggerScenarios":"An edit line 'adddep -node gov ...' that omits the -reln flag; a -reln value consumed by the wrong pairing in parseArgs (e.g. due to an earlier unmatched quote shifting arg pairs).","commonSituations":"Writing adddep rules from memory and forgetting -reln; rule templates from other ssurgeon ops (like addnode) that don't need -reln; a malformed argument list silently swallowing the -reln value.","solutions":["Add -reln <relation> to the adddep edit line, e.g. -reln obl.","Use a relation name valid for the chosen language (GrammaticalRelation.valueOf(language, reln) runs next and will fail on bad names).","Check the argument pairing on the line — a stray quote earlier can offset -flag/-value pairs so -reln is lost."],"exampleFix":"// before\nadddep -node governor -dep newnode\n// after\nadddep -node governor -dep newnode -reln nmod","handlingStrategy":"validation","validationCode":"if (line.startsWith(\"adddep\") && !line.matches(\".*-reln\\\\s+\\\\S+.*\"))\n  throw new IllegalArgumentException(\"adddep line missing -reln: \" + line);","typeGuard":null,"tryCatchPattern":"try { parseEditLine(line, attrs, lang); } catch (SsurgeonParseException e) { if (e.getMessage().equals(\"Relation not specified for AddDep\")) log.error(\"Add -reln to: \" + line); }","preventionTips":["Always include -reln on adddep lines","Use relation names valid for the selected language","Keep a rule-file lint that checks required flags per op"],"tags":["parsing","ssurgeon","missing-argument"],"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"}