{"record":{"id":"bef1849c68d4a1f3","repo":"stanfordnlp/CoreNLP","slug":"relabelnamededge-created-with-no-edge-name","errorCode":null,"errorMessage":"RelabelNamedEdge created with no edge name!","messagePattern":"RelabelNamedEdge created with no edge name!","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/RelabelNamedEdge.java","lineNumber":31,"sourceCode":" * then put it back with the updated relation.\n *<br>\n * If an edge already exists with the new named relation,\n * <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(\" \");","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/RelabelNamedEdge.java#L13-L49","documentation":"RelabelNamedEdge changes the GrammaticalRelation of an edge matched and named in the SemgrexPattern. It needs the edge name to identify the edge; a null edgeName makes the operation unusable, so the constructor throws.","triggerScenarios":"new RelabelNamedEdge(null, relation), or an Ssurgeon resource line 'relabel-named-edge' missing the named-edge argument.","commonSituations":"Malformed Ssurgeon rule file where the edge name token was dropped; programmatic construction where the edge-name string is null because the SemgrexPattern never named an edge; renaming an edge in the pattern without updating the operation.","solutions":["Pass the name given to the edge in the SemgrexPattern (edge=...) as the first argument","Ensure the resource line reads e.g. relabel-named-edge -edge myEdge -reln nsubj","Confirm the SemgrexPattern contains an edge= clause with that exact name"],"exampleFix":"// before\nnew RelabelNamedEdge(null, UniversalGrammaticalRelations.NOMINAL_SUBJECT);\n// after\nnew RelabelNamedEdge(\"myEdge\", UniversalGrammaticalRelations.NOMINAL_SUBJECT);","handlingStrategy":"validation","validationCode":"if (edgeName == null || edgeName.isEmpty()) {\n  throw new IllegalArgumentException(\"relabel-named-edge requires the named edge from the SemgrexPattern\");\n}\nif (!patternNamesEdges.contains(edgeName)) {\n  throw new IllegalArgumentException(\"No edge named \" + edgeName + \" in the SemgrexPattern\");\n}","typeGuard":"boolean edgeIsNamed(String name, Set<String> patternEdgeNames) { return name != null && patternEdgeNames.contains(name); }","tryCatchPattern":"try {\n  op = new RelabelNamedEdge(edgeName, relation);\n} catch (SsurgeonParseException e) {\n  log.error(\"Invalid relabel rule: {}\", e.getMessage());\n  throw new RuleSyntaxException(e);\n}","preventionTips":["Ensure the SemgrexPattern contains an edge= clause matching the operation's edge name","Pair-edit pattern and operation so edge names stay in sync","Load and dry-run all Ssurgeon rules in a unit test before production use"],"tags":["java","ssurgeon","null-argument"],"backgroundTag":"null-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"}