{"record":{"id":"4882ad8a64228aae","repo":"stanfordnlp/CoreNLP","slug":"relabelnamededge-created-with-no-relation","errorCode":null,"errorMessage":"RelabelNamedEdge created with no relation!","messagePattern":"RelabelNamedEdge created with no relation!","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/RelabelNamedEdge.java","lineNumber":34,"sourceCode":" * <i>that</i> edge is deleted permanently.  That way, named\n * references to the first edge should still work.\n *\n * @author John Bauer\n *\n */\npublic class RelabelNamedEdge extends SsurgeonEdit {  \n  public static final String LABEL = \"relabelNamedEdge\";\n\n  protected final String edgeName; // Name of the matched edge in the SemgrexPattern\n\n  protected final GrammaticalRelation relation; // Type of relation to add between these edges\n\n  public RelabelNamedEdge(String edgeName, GrammaticalRelation relation) {\n    if (edgeName == null) {\n      throw new SsurgeonParseException(\"RelabelNamedEdge created with no edge name!\");\n    }\n    if (relation == null) {\n      throw new SsurgeonParseException(\"RelabelNamedEdge created with no relation!\");\n    }\n\n    this.edgeName = edgeName;\n    this.relation = relation;\n  }\n\n  @Override\n  public String toEditString() {\n    StringWriter buf = new StringWriter();\n    buf.write(LABEL); buf.write(\"\\t\");\n\n    buf.write(Ssurgeon.EDGE_NAME_ARG);buf.write(\" \");    \n    buf.write(edgeName); buf.write(\"\\t\");\n\n    buf.write(Ssurgeon.RELN_ARG);buf.write(\" \");\n    buf.write(relation.toString()); buf.write(\"\\t\");\n\n    return buf.toString();","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/RelabelNamedEdge.java#L16-L52","documentation":"SsurgeonParseException from RelabelNamedEdge's constructor when it is created with a null edge name or null relation; a relabel operation must know which named matched edge to modify and what relation to assign.","triggerScenarios":"new RelabelNamedEdge(edgeName, null), or a relabel-named-edge Ssurgeon resource line with a missing or unparseable -reln argument.","commonSituations":"Typo in the relation name in a rule file so the parser yields null; constructing the operation from a config where the relation field is absent; using a relation string that cannot resolve to a GrammaticalRelation.","solutions":["Pass a valid GrammaticalRelation instance, e.g. UniversalGrammaticalRelations.DIRECT_OBJECT or GrammaticalRelation.valueOf(\"dobj\")","Fix the -reln argument in the resource line to a valid universal relation short name","Use the relations from edu.stanford.nlp.trees.UniversalGrammaticalRelations rather than null placeholders"],"exampleFix":"// before\nnew RelabelNamedEdge(\"myEdge\", null);\n// after\nnew RelabelNamedEdge(\"myEdge\", UniversalGrammaticalRelations.NOMINAL_SUBJECT);","handlingStrategy":"validation","validationCode":"if (relation == null) {\n  throw new IllegalArgumentException(\"relabel-named-edge requires a -reln GrammaticalRelation\");\n}","typeGuard":"boolean isValidRelation(GrammaticalRelation r) { return r != null && r.getShortName() != null; }","tryCatchPattern":"try {\n  op = new RelabelNamedEdge(edgeName, relation);\n} catch (SsurgeonParseException e) {\n  log.error(\"Missing/invalid relation: {}\", e.getMessage());\n  op = new RelabelNamedEdge(edgeName, UniversalGrammaticalRelations.DEPENDENT);\n}","preventionTips":["Reference relations from UniversalGrammaticalRelations constants rather than parsing strings ad hoc","Validate relation short names in rules against the known UD set","Fail fast in rule loading tests by constructing every operation once"],"tags":["java","ssurgeon","null-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"}