{"record":{"id":"2d10e1a1331ab5cc","repo":"apache/beam","slug":"unable-to-locate-window-for-successful-request","errorCode":null,"errorMessage":"Unable to locate window for successful request","messagePattern":"Unable to locate window for successful request","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java","lineNumber":532,"sourceCode":"          }\n          return DoFlushStatus.ONE_OR_MORE_FAILURES;\n        }\n      }\n    }\n\n    /**\n     * Window values are part of the WriteElement which is used to full the flushBuffer and\n     * accessible after the response is returned. Our FlushBuffer is ensured to be non-empty before\n     * passed to this method, so the loop above will always iterate at least once and by virtue of\n     * this method only being when at least one ok status OK is present successfulWindow will be\n     * non-null.\n     *\n     * <p>This method is here to prove to error prone that the value of successfulWindow we are\n     * passing along is in fact non-null.\n     */\n    private static BoundedWindow coerceNonNull(@Nullable BoundedWindow successfulWindow) {\n      if (successfulWindow == null) {\n        throw new IllegalStateException(\"Unable to locate window for successful request\");\n      }\n      return successfulWindow;\n    }\n\n    private enum DoFlushStatus {\n      OK,\n      ONE_OR_MORE_FAILURES\n    }\n\n    abstract void handleWriteFailures(\n        ContextAdapter<OutT> context,\n        List<KV<WriteFailure, BoundedWindow>> writeFailures,\n        Runnable logMessage);\n\n    abstract void handleWriteSummary(\n        ContextAdapter<OutT> context,\n        Instant timestamp,\n        KV<WriteSuccessSummary, BoundedWindow> tuple,","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreV1WriteFn.java#L514-L550","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade apache-beam (google-cloud-platform) to the latest release where flush/window bookkeeping fixes are included","If reproducible, capture the DoFn stack trace and file a Beam Jira issue (BEAM-*) with the pipeline topology","Work around by restructuring the write (smaller batches / fewer concurrent windows) to reduce the race window","As a stopgap, catch the failure in the error-handling output so the bundle can proceed without crashing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"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; } }","preventionTips":["Use a recent Beam release; this is an internal invariant and mostly fixed upstream","Avoid extreme batching configs (very large groups/many concurrent windows) that stress flush bookkeeping","Route write failures to an error-handling output rather than crashing the bundle"],"tags":["firestore","beam","write","windowing","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}