{"record":{"id":"36045ef6e557f908","repo":"stanfordnlp/CoreNLP","slug":"invalid-hypgraph","errorCode":null,"errorMessage":"Invalid hypGraph ","messagePattern":"Invalid hypGraph ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/Alignment.java","lineNumber":162,"sourceCode":"\n\n  /**\n   * Constructs and returns a new Alignment from the given hypothesis\n   * {@code SemanticGraph} to the given text (passage) SemanticGraph, using\n   * the given array of indexes.  The i'th node of the array should contain the\n   * index of the node in the text (passage) SemanticGraph to which the i'th\n   * node in the hypothesis SemanticGraph is aligned, or -1 if it is aligned to\n   * NO_WORD.\n   */\n  public static Alignment makeFromIndexArray(SemanticGraph txtGraph,\n                                             SemanticGraph hypGraph,\n                                             int[] indexes,\n                                             double score,\n                                             String justification) {\n    if (txtGraph == null || txtGraph.isEmpty())\n      throw new IllegalArgumentException(\"Invalid txtGraph \" + txtGraph);\n    if (hypGraph == null || hypGraph.isEmpty())\n      throw new IllegalArgumentException(\"Invalid hypGraph \" + hypGraph);\n    if (indexes == null)\n      throw new IllegalArgumentException(\"Null index array\");\n    if (indexes.length != hypGraph.size())\n      throw new IllegalArgumentException(\"Index array length \" + indexes.length +\n                                         \" does not match hypGraph size \" + hypGraph.size());\n    Map<IndexedWord, IndexedWord> map =\n      Generics.newHashMap();\n    for (int i = 0; i < indexes.length; i++) {\n      IndexedWord hypNode = hypGraph.getNodeByIndex(i);\n      IndexedWord txtNode = IndexedWord.NO_WORD;\n      if (indexes[i] >= 0)\n        txtNode = txtGraph.getNodeByIndex(indexes[i]);\n      map.put(hypNode, txtNode);\n    }\n    return new Alignment(map, score, justification);\n  }\n\n  public static Alignment makeFromIndexArray(SemanticGraph txtGraph,","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/Alignment.java#L144-L180","documentation":"Alignment.makeFromIndexArray throws IllegalArgumentException(\"Invalid hypGraph \" + hypGraph) when the hypothesis SemanticGraph is null or empty. The index array is sized against the hyp graph, so an empty/null hyp graph makes the alignment undefined.","triggerScenarios":"Calling makeFromIndexArray with hypGraph == null or a zero-vertex SemanticGraph, typically from an empty hypothesis sentence parse.","commonSituations":"Entailment/RTE pipelines feeding unpopulated hypothesis graphs after failed parsing; null propagation through match/alignment chains.","solutions":["Verify hypGraph != null && hypGraph.size() > 0 before the call","Also ensure indexes.length equals hypGraph.size() (the next precondition checked)","Filter out empty hypothesis graphs earlier in the pipeline"],"exampleFix":"// before\nAlignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, idx, 1.0, \"j\");\n// after\nif (hypGraph != null && hypGraph.size() > 0 && idx.length == hypGraph.size()) {\n  Alignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, idx, 1.0, \"j\");\n}","handlingStrategy":"validation","validationCode":"if (hypGraph != null && hypGraph.size() > 0 && indexes != null && indexes.length == hypGraph.size()) { Alignment a = Alignment.makeFromIndexArray(txtGraph, hypGraph, indexes, score, just); }","typeGuard":"boolean validHyp = h != null && !h.isEmpty() && indexes != null && indexes.length == h.size();","tryCatchPattern":"try { a = Alignment.makeFromIndexArray(txt, hyp, idx, score, just); } catch (IllegalArgumentException e) { log.warn(\"Alignment skipped: \" + e.getMessage()); }","preventionTips":["Check hyp graph population before indexing against it","Keep indexes array length synced to hypGraph.size()","Filter empty hypothesis sentences earlier in the pipeline"],"tags":["java","nlp","semgrex","argument-validation"],"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"}