apache/beam · error · PipelineRunMissingException

The pipeline has not been run.

Error message

The pipeline has not been run.

What it means

TestPipeline verifies, after the test body finishes, that a non-empty pipeline was actually run. If runAttempted is false (and auto-run is not enabled) it throws PipelineRunMissingException with this message, because assertions like PAssert only evaluate when the pipeline executes.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/testing/TestPipeline.java:215

    private List<TransformHierarchy.Node> recordPipelineNodes(final Pipeline pipeline) {
      final NodeRecorder nodeRecorder = new NodeRecorder();
      pipeline.traverseTopologically(nodeRecorder);
      return nodeRecorder.visited;
    }

    private boolean isEmptyPipeline(final Pipeline pipeline) {
      final IsEmptyVisitor isEmptyVisitor = new IsEmptyVisitor();
      pipeline.traverseTopologically(isEmptyVisitor);
      return isEmptyVisitor.isEmpty();
    }

    private void verifyPipelineExecution() {
      if (isEmptyPipeline(pipeline)) {
        return;
      }

      if (!runAttempted && !enableAutoRunIfMissing) {
        throw new PipelineRunMissingException("The pipeline has not been run.");
      }

      if (!pipelineRunSucceeded()) {
        return; // this method is to protect against spurious success, so failure is fine
      }

      final List<TransformHierarchy.Node> runVisitedNodes =
          checkStateNotNull(
              this.runVisitedNodes,
              "Internal error: non-empty pipeline has been visited but still no runVisitedNodes");
      final List<TransformHierarchy.Node> pipelineNodes = recordPipelineNodes(pipeline);
      if (runVisitedNodes.equals(pipelineNodes)) {
        return;
      }

      final boolean hasDanglingPAssert =
          pipelineNodes.stream()
              .filter(Predicates.not(Predicates.in(runVisitedNodes)))

View on GitHub (pinned to 12126d8942)

Solutions

  1. Call pipeline.run().waitUntilFinish() at the end of the test.
  2. Enable auto-run of missing pipelines in test options if your workflow expects implicit runs (Beam can auto-run pipelines in tests via TestPipeline rule flags).
  3. If the test intentionally builds no pipeline, keep it empty so isEmptyPipeline() short-circuits.

Example fix

// before
PAssert.that(pcoll).containsInAnyOrder("a");
// after
PAssert.that(pcoll).containsInAnyOrder("a");
pipeline.run().waitUntilFinish();
Defensive patterns

Strategy: validation

Validate before calling

if (builtTransforms > 0 && !runAttempted) { throw new IllegalStateException("Test forgot pipeline.run()"); }

Try / catch

try { testLogic(); } catch (PipelineRunMissingException e) { fail("Add pipeline.run().waitUntilFinish() to the test"); }

Prevention

When it happens

Trigger: Creating a TestPipeline, applying transforms/PAsserts, but never calling pipeline.run() before the test method ends; run() commented out or guarded behind a condition that never fires.

Common situations: Test refactorings that drop the run() call; tests skipped mid-way with early returns before run(); forgetting run() when switching from direct construction to TestPipeline.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1c0a2205d16d9bb7. Report an issue: GitHub.