{"record":{"id":"ebcdc68c5f9fc7b5","repo":"stanfordnlp/CoreNLP","slug":"no-semanticgraph-vertex-with-index-index-and","errorCode":null,"errorMessage":"No SemanticGraph vertex with index  + index +  and copyCount  + copyCount","messagePattern":"No SemanticGraph vertex with index  \\+ index \\+  and copyCount  \\+ copyCount","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/SemanticGraph.java","lineNumber":632,"sourceCode":"   */\n  public IndexedWord getNodeByIndexSafe(int index) {\n    for (IndexedWord vertex : vertexSet()) {\n      if (vertex.index() == index) {\n        return vertex;\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Returns the <em>first</em> {@link edu.stanford.nlp.ling.IndexedWord\n   * IndexedWord} in this {@code SemanticGraph} having the given integer index,\n   * or throws {@code IllegalArgumentException} if no such node is found.\n   */\n  public IndexedWord getNodeByIndexAndCopyCount(int index, int copyCount) throws IllegalArgumentException {\n    IndexedWord node = getNodeByIndexAndCopyCountSafe(index, copyCount);\n    if (node == null)\n      throw new IllegalArgumentException(\"No SemanticGraph vertex with index \" + index + \" and copyCount \" + copyCount);\n    else\n      return node;\n  }\n\n  /**\n   * Same as above, but returns {@code null} if the index does not exist\n   * (instead of throwing an exception).\n   */\n  public IndexedWord getNodeByIndexAndCopyCountSafe(int index, int copyCount) {\n    for (IndexedWord vertex : vertexSet()) {\n      if (vertex.index() == index && vertex.copyCount() == copyCount) {\n        return vertex;\n      }\n    }\n    return null;\n  }\n\n  /**","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/SemanticGraph.java#L614-L650","documentation":"SemanticGraph.getNodeByIndexAndCopyCount resolves a vertex by both its index and its copyCount (used for copied nodes, e.g. enhanced/copy edges produced by Universal Dependencies 'copy' annotations) and throws IllegalArgumentException when no vertex matches both values. The Safe variant returns null instead of throwing.","triggerScenarios":"Calling getNodeByIndexAndCopyCount(index, copyCount) where the graph contains a node with that index but a different copyCount, or where no copied node exists at all (copyCount not in the graph's copyCounts(vertex) set).","commonSituations":"Reading enhanced UD graphs with copy nodes using a copyCount that was valid in a previous parse; assuming copyCount starts at a different value than the library uses; graphs built from CoNLL data that dropped copy annotations.","solutions":["Call getNodeByIndexAndCopyCountSafe and handle null","Enumerate copyCounts(graph.getNodeByIndexSafe(index)) to see which copyCounts actually exist before requesting","Confirm the input graph is an enhanced/copy-annotated graph; on basic graphs copyCount semantics do not apply","Regenerate indices/copyCounts from the same parse run rather than caching them across parses"],"exampleFix":"// before\nIndexedWord node = graph.getNodeByIndexAndCopyCount(idx, copy);\n// after\nIndexedWord node = graph.getNodeByIndexAndCopyCountSafe(idx, copy);\nif (node == null) { /* fall back to getNodeByIndexSafe(idx) or skip */ }","handlingStrategy":"validation","validationCode":"boolean hasIndexCopy(SemanticGraph g, int idx, int copy) {\n  return g.getNodeByIndexAndCopyCountSafe(idx, copy) != null;\n}","typeGuard":"IndexedWord node = graph.getNodeByIndexAndCopyCountSafe(index, copyCount);\nif (node == null) {\n  node = graph.getNodeByIndexSafe(index); // graceful fallback\n}","tryCatchPattern":"try {\n  IndexedWord n = graph.getNodeByIndexAndCopyCount(idx, copy);\n} catch (IllegalArgumentException e) {\n  // inspect copyCounts(vertexSet()) to see valid copyCounts\n}","preventionTips":["Only use copyCount lookups on enhanced/copy-annotated graphs","Enumerate copyCounts() to learn the valid values before querying","Do not carry copyCounts across different parse runs","Fall back to the index-only Safe lookup when copyCount is missing"],"tags":["semantic-graph","lookup","copy-count","ud-enhanced"],"backgroundTag":"record-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"}