{"record":{"id":"3d751b7acb5161e2","repo":"stanfordnlp/CoreNLP","slug":"unsupported-dependency-type","errorCode":null,"errorMessage":"Unsupported dependency type: ","messagePattern":"Unsupported dependency type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/simple/Sentence.java","lineNumber":658,"sourceCode":"  }\n\n  /** @see Sentence#parse(java.util.Properties) */\n  public Tree parse() {\n    return parse(this.defaultProps);\n  }\n\n\n  /** An internal helper to get the dependency tree of the given type. */\n  private CoreNLPProtos.DependencyGraph dependencies(SemanticGraphFactory.Mode mode) {\n    switch (mode) {\n      case BASIC:\n        return impl.getBasicDependencies();\n      case ENHANCED:\n        return impl.getEnhancedDependencies();\n      case ENHANCED_PLUS_PLUS:\n        return impl.getEnhancedPlusPlusDependencies();\n      default:\n        throw new IllegalArgumentException(\"Unsupported dependency type: \" + mode);\n    }\n  }\n\n  /**\n   * Returns the governor of the given index, according to the passed dependency type.\n   * The root has index -1.\n   *\n   * @param props The properties to use in the parser annotator.\n   * @param index The index of the dependent word ZERO INDEXED. That is, the first word of the sentence\n   *              is index 0, not 1 as it would be in the {@link edu.stanford.nlp.semgraph.SemanticGraph} framework.\n   * @param mode  The type of dependency to use (e.g., basic, collapsed, collapsed cc processed).\n   * @return The index of the governor, if one exists. A value of -1 indicates the root node.\n   */\n  public Optional<Integer> governor(Properties props, int index, SemanticGraphFactory.Mode mode) {\n    document.runDepparse(props);\n    for (CoreNLPProtos.DependencyGraph.Edge edge : dependencies(mode).getEdgeList()) {\n      if (edge.getTarget() - 1 == index) {\n        return Optional.of(edge.getSource() - 1);","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/simple/Sentence.java#L640-L676","documentation":"Sentence's internal call to impl.dependencies(mode) hits the default branch of a switch over GrammaticalStructure.DependencyMode when the mode value is unrecognized, throwing IllegalArgumentException with 'Unsupported dependency type: ' + mode. In practice the three enum cases (BASIC, ENHANCED, ENHANCED_PLUS_PLUS) cover all values, so this is a defensive invariant guard reached only if a new enum constant is added without updating this switch.","triggerScenarios":"Calling Sentence.dependencies(), governors(), governor(), incomingDependencyLabel(s), or dependencyGraph() with a dependency mode that the underlying impl does not map; mainly occurs after custom extensions or a version mismatch introducing a new DependencyMode constant.","commonSituations":"Upgrading CoreNLP where a new DependencyMode was added but Sentence's switch not updated; reflection or serialization restoring a stale/unexpected mode value.","solutions":["Use only DependencyMode.BASIC, ENHANCED, or ENHANCED_PLUS_PLUS","Upgrade/align CoreNLP jars so the enum and Sentence come from the same version","Check for library bug if it occurs with stock API and report to CoreNLP maintainers"],"exampleFix":"// before\nSemanticGraph g = sentence.dependencies(GrammaticalStructure.DependencyMode.ENHANCED_PLUS_PLUS);\n// after\nif (mode != BASIC && mode != ENHANCED && mode != ENHANCED_PLUS_PLUS) {\n  mode = GrammaticalStructure.DependencyMode.BASIC;\n}\nSemanticGraph g = sentence.dependencies(mode);","handlingStrategy":"validation","validationCode":"// restrict mode to known values\nif (mode != GrammaticalStructure.DependencyMode.BASIC\n && mode != GrammaticalStructure.DependencyMode.ENHANCED\n && mode != GrammaticalStructure.DependencyMode.ENHANCED_PLUS_PLUS) {\n  mode = GrammaticalStructure.DependencyMode.BASIC;\n}","typeGuard":"boolean isValidDependencyMode(GrammaticalStructure.DependencyMode m) {\n  return m == BASIC || m == ENHANCED || m == ENHANCED_PLUS_PLUS;\n}","tryCatchPattern":"try {\n  SemanticGraph g = sentence.dependencies(mode);\n} catch (IllegalArgumentException e) {\n  SemanticGraph g = sentence.dependencies(GrammaticalStructure.DependencyMode.BASIC);\n}","preventionTips":["Use only the three documented DependencyMode constants","Keep all CoreNLP jars at one version","Pin CoreNLP version in your build to avoid enum drift"],"tags":["corenlp","dependencies","switch-default"],"backgroundTag":"invalid-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"}