apache/beam · error · IllegalStateException

Unable to locate window for successful request

Error message

Unable to locate window for successful request

What it means

coerceNonNull exists solely to satisfy Error Prone's nullness analysis when associating a successful write request with a window. If the tracked successfulWindow is null at flush time despite a successful request having been recorded, the invariant 'a success implies a window' is broken and this IllegalStateException is thrown.

Solutions

  1. Upgrade apache-beam (google-cloud-platform) to the latest release where flush/window bookkeeping fixes are included
  2. If reproducible, capture the DoFn stack trace and file a Beam Jira issue (BEAM-*) with the pipeline topology
  3. Work around by restructuring the write (smaller batches / fewer concurrent windows) to reduce the race window
  4. As a stopgap, catch the failure in the error-handling output so the bundle can proceed without crashing
Defensive patterns

Strategy: try-catch

Try / catch

try { /* write flush */ } catch (IllegalStateException e) { if (e.getMessage().contains("Unable to locate window")) { // treat batch as failed, re-buffer or route to error output } else { throw e; } }

Prevention

When it happens

Trigger: doFlush reports an OK/OK_BATCHED status but no window was recorded alongside the successful request — an internal state bug in FirestoreV1WriteFn's batching, typically under retry/bundle-failure edge cases.

Common situations: Race between batching and window bookkeeping under heavy load; connector bugs surfaced in production; interactions with resharding or bundle retries that lose the successful-request window.

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 apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/2d10e1a1331ab5cc. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java:532

          }
          return DoFlushStatus.ONE_OR_MORE_FAILURES;
        }
      }
    }

    /**
     * Window values are part of the WriteElement which is used to full the flushBuffer and
     * accessible after the response is returned. Our FlushBuffer is ensured to be non-empty before
     * passed to this method, so the loop above will always iterate at least once and by virtue of
     * this method only being when at least one ok status OK is present successfulWindow will be
     * non-null.
     *
     * <p>This method is here to prove to error prone that the value of successfulWindow we are
     * passing along is in fact non-null.
     */
    private static BoundedWindow coerceNonNull(@Nullable BoundedWindow successfulWindow) {
      if (successfulWindow == null) {
        throw new IllegalStateException("Unable to locate window for successful request");
      }
      return successfulWindow;
    }

    private enum DoFlushStatus {
      OK,
      ONE_OR_MORE_FAILURES
    }

    abstract void handleWriteFailures(
        ContextAdapter<OutT> context,
        List<KV<WriteFailure, BoundedWindow>> writeFailures,
        Runnable logMessage);

    abstract void handleWriteSummary(
        ContextAdapter<OutT> context,
        Instant timestamp,
        KV<WriteSuccessSummary, BoundedWindow> tuple,

View on GitHub (pinned to 12126d8942)