stanfordnlp/CoreNLP · error · RuntimeException

Between when the incoming edge was found and now, the edge…

Error message

Between when the incoming edge was found and now, the edge was somehow deleted

What it means

In SetPhraseHead.evaluate(), incoming edges to the old head are re-created with a new source; before rebuilding each one, sg.removeEdge(edge) must succeed. A false return means the incoming edge disappeared between discovery and removal, so the operation throws this RuntimeException to avoid silently corrupting the dependency graph.

Solutions

  1. Re-run the semgrex match before applying the edit so edge references reflect the current graph
  2. Order ssurgeon operations so nothing removes incoming edges before SetPhraseHead runs
  3. Reset/reload the SemanticGraph between repeated test invocations of the same rule
  4. Verify removeEdge on your SemanticGraph implementation matches the exact edge instance

Example fix

// before: reusing edges matched before other edits
for (SemanticGraphEdge e : matchedEdges) { applyEdit(sg, e); }
// after: re-match after each mutating step
SemgrexMatcher sm = pattern.matcher(sg);
if (sm.find()) { SetPhraseHead op = ...; op.evaluate(sg, sm); }
Defensive patterns

Strategy: try-catch

Validate before calling

// confirm all incoming edges to the head are present before evaluate
for (SemanticGraphEdge e : collectedIncoming) {
  if (sg.getEdge(e.getSource(), e.getTarget(), e.getRelation()) == null) throw new IllegalStateException("stale edge");
}

Try / catch

try { op.evaluate(sg, sm); } catch (RuntimeException e) { if (e.getMessage().contains("incoming edge was somehow deleted")) { /* re-match and retry on fresh graph */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling evaluate() when the SemanticGraph's incoming edges were removed by a prior operation in the same ssurgeon pass, or the edge objects were collected from a stale/different graph instance.

Common situations: Chaining multiple Ssurgeon operations where an earlier operation (e.g. another SetPhraseHead or DeleteGraph) deletes edges into the head; re-running a test that mutated a shared SemanticGraph fixture.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/16b7df5b1a15ab47. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/SetPhraseHead.java:142

                                                        edgeOut.getWeight(),
                                                        edgeOut.isExtra());
      boolean success = sg.removeEdge(edgeOut);
      if (!success) {
        throw new RuntimeException("Between when the outgoing edge was found and now, the edge was somehow deleted");
      }
      sg.addEdge(newEdge);
      modified = true;
    }

    for (SemanticGraphEdge edge : relocateEdges) {
      SemanticGraphEdge newEdge = new SemanticGraphEdge(newHead,
                                                        edge.getTarget(),
                                                        edge.getRelation(),
                                                        edge.getWeight(),
                                                        edge.isExtra());
      boolean success = sg.removeEdge(edge);
      if (!success) {
        throw new RuntimeException("Between when the incoming edge was found and now, the edge was somehow deleted");
      }
      sg.addEdge(newEdge);
      modified = true;
    }

    for (SemanticGraphEdge edge : deleteEdges) {
      boolean success = sg.removeEdge(edge);
      if (!success) {
        throw new RuntimeException("Between when the internal phrase edge was found and now, the edge was somehow deleted");
      }
      modified = true;
    }
    for (IndexedWord other : matchedNodes) {
      if (other == newHead)
        continue;

      found: {
        for (SemanticGraphEdge existingEdge : sg.getAllEdges(newHead, other)) {

View on GitHub (pinned to 1b7edd19c4)