{"record":{"id":"2a179328bb64ae45","repo":"stanfordnlp/CoreNLP","slug":"error-haven-t-dealt-with-relation-relation","errorCode":null,"errorMessage":"Error: Haven't dealt with relation \" + relation + \" yet.","messagePattern":"Error: Haven't dealt with relation \" \\+ relation \\+ \" yet\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/tregex/tsurgeon/TreeLocation.java","lineNumber":73,"sourceCode":"        newIndex = Integer.parseInt(m.group(1))-1;\n        parent = relativeNode;\n        if(relation.charAt(1)=='-') // backwards.\n          newIndex = parent.children().length - newIndex;\n      } else {\n        parent = relativeNode.parent(tree);\n        if (parent == null) {\n          throw new RuntimeException(\"Error: looking for a non-existent parent in tree \" + tree + \" for \\\"\" + toString() + '\"');\n        }\n        int index = parent.objectIndexOf(relativeNode);\n        switch(relation) {\n          case \"$+\" :\n            newIndex = index;\n            break;\n          case \"$-\" :\n            newIndex = index+1;\n            break;\n          default :\n            throw new RuntimeException(\"Error: Haven't dealt with relation \" + relation + \" yet.\");\n        }\n      }\n      return new Pair<>(parent, newIndex);\n    }\n  }\n\n  @Override\n  public String toString() {\n    return relation + ' ' + child;\n  }\n\n}\n","sourceCodeStart":55,"sourceCodeEnd":86,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/tregex/tsurgeon/TreeLocation.java#L55-L86","documentation":"TreeLocation.evaluate handles only the $+ and $- (right/left sister) relations in its switch; any other relation string reaching this code path hits the default branch and throws \"Haven't dealt with relation X yet\". It signals an unsupported or malformed relation in a tsurgeon location expression.","triggerScenarios":"Calling TreeLocation.evaluate with a relation string other than \"$+\" or \"$-\", e.g. a typo like \"$++\", \"$\", or a relation inserted programmatically rather than parsed by TsurgeonParser.","commonSituations":"Hand-constructing Tsurgeon internals instead of using parseOperation; typos in relation names in tsurgeon scripts; library version where a new relation is used but TreeLocation hasn't been updated.","solutions":["Correct the relation to \"$+\" or \"$-\" in the tsurgeon expression","Parse the operation through Tsurgeon.parseOperation so malformed relations are rejected up front with a clearer TsurgeonParseException","If a new relation is needed, extend the switch in TreeLocation.evaluate"],"exampleFix":"// before\nparseOperation(\"insert (NP foo) $~NP\");\n// after\nparseOperation(\"insert (NP foo) $+NP\");","handlingStrategy":"validation","validationCode":"Set<String> supported = Set.of(\"$+\", \"$\");\n// validate relations in the tsurgeon script before evaluating\nboolean ok = scriptRelations.stream().allMatch(supported::contains);","typeGuard":"null","tryCatchPattern":"try { evaluate(loc, tree); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Error: Haven't dealt with relation\")) { throw new IllegalArgumentException(\"Unsupported tsurgeon relation\", e); } throw e; }","preventionTips":["Use only documented tsurgeon relations ($+, $-)","Parse scripts through Tsurgeon.parseOperation instead of building internals manually","Keep parser and TreeLocation versions in sync when upgrading Stanford CoreNLP"],"tags":["tregex","tsurgeon","unsupported-relation","runtime-exception"],"backgroundTag":"unsupported-enum-value","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"}