{"record":{"id":"ef5ee5ca9f5f7dda","repo":"stanfordnlp/CoreNLP","slug":"unknown-vertex","errorCode":null,"errorMessage":"Unknown vertex","messagePattern":"Unknown vertex","errorType":"exception","errorClass":"UnknownVertexException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/SemanticGraph.java","lineNumber":701,"sourceCode":"  public List<IndexedWord> getAllNodesByPartOfSpeechPattern(String pattern) {\n    Pattern p = Pattern.compile(pattern);\n    List<IndexedWord> nodes = new ArrayList<>();\n    for (IndexedWord vertex : vertexSet()) {\n      String pos = vertex.tag();\n      if ((pos == null && pattern == null) || pos != null && p.matcher(pos).matches()) {\n        nodes.add(vertex);\n      }\n    }\n    return nodes;\n  }\n\n  /**\n   * Returns the set of descendants governed by this node in the graph.\n   *\n   */\n  public Set<IndexedWord> descendants(IndexedWord vertex) {\n    if (!containsVertex(vertex)) {\n      throw new UnknownVertexException(vertex, this);\n    }\n    // Do a depth first search\n    Set<IndexedWord> descendantSet = wordMapFactory.newSet();\n    descendantsHelper(vertex, descendantSet);\n    return descendantSet;\n  }\n\n  private void descendantsHelper(IndexedWord curr, Set<IndexedWord> descendantSet) {\n    if (descendantSet.contains(curr)) {\n      return;\n    }\n    descendantSet.add(curr);\n    for (IndexedWord child : getChildren(curr)) {\n      descendantsHelper(child, descendantSet);\n    }\n  }\n\n  /**","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/SemanticGraph.java#L683-L719","documentation":"SemanticGraph.descendants(vertex) computes the transitive set of nodes governed by the given vertex via depth-first search, and throws UnknownVertexException if the vertex is not present in this graph. Each graph method validates membership first, so passing a node from a different (or rebuilt) graph always throws.","triggerScenarios":"Calling descendants with an IndexedWord obtained from another SemanticGraph instance, or from a vertex whose backing document/graph was re-created, or after the node was removed from this graph.","commonSituations":"Comparing nodes across basic vs enhanced graphs; keeping IndexedWord references across pipeline stages that rebuild the parse; copy constructors that create a new graph while old vertex references are reused.","solutions":["Check graph.containsVertex(vertex) before calling descendants","Ensure the vertex came from the same graph instance (same parse), not another graph or a stale reference","Use the Safe getter methods to re-resolve the vertex by index on the current graph","Restructure code so vertex references do not outlive the graph they belong to"],"exampleFix":"// before\nSet<IndexedWord> desc = graph.descendants(v);\n// after\nif (graph.containsVertex(v)) {\n  Set<IndexedWord> desc = graph.descendants(v);\n} else { /* re-resolve by index or handle */ }","handlingStrategy":"type-guard","validationCode":"if (!graph.containsVertex(v)) { throw new IllegalStateException(\"vertex not in graph\"); }","typeGuard":"IndexedWord resolve(SemanticGraph g, IndexedWord maybeStale, int index) {\n  return g.containsVertex(maybeStale) ? maybeStale : g.getNodeByIndexSafe(index);\n}","tryCatchPattern":"try {\n  Set<IndexedWord> desc = graph.descendants(v);\n} catch (UnknownVertexException e) {\n  // re-resolve v by index on the current graph\n}","preventionTips":["Never reuse IndexedWord references across different SemanticGraph instances","Re-resolve vertices by index after graph transformations","Wrap vertex caches as (graph, vertex) pairs","Check containsVertex before any traversal API"],"tags":["semantic-graph","vertex","graph-membership"],"backgroundTag":"resource-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}