{"record":{"id":"b47f553788d73270","repo":"apache/beam","slug":"calling-triggering-to-specify-a-trigger-or-calling","errorCode":null,"errorMessage":"Calling .triggering() to specify a trigger or calling .withAllowedLateness() to specify an allowed lateness greater than zero requires that the accumulation mode be specified using .discardingFiredPanes() or .accumulatingFiredPanes(). See Javadoc for more details.","messagePattern":"Calling \\.triggering\\(\\) to specify a trigger or calling \\.withAllowedLateness\\(\\) to specify an allowed lateness greater than zero requires that the accumulation mode be specified using \\.discardingFiredPanes\\(\\) or \\.accumulatingFiredPanes\\(\\)\\. See Javadoc for more details\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Window.java","lineNumber":368,"sourceCode":"\n  private void applicableTo(PCollection<?> input) {\n    WindowingStrategy<?, ?> outputStrategy =\n        getOutputStrategyInternal(input.getWindowingStrategy());\n\n    // Make sure that the windowing strategy is complete & valid.\n    if (outputStrategy.isTriggerSpecified()\n        && !(outputStrategy.getTrigger() instanceof DefaultTrigger)\n        && !(outputStrategy.getWindowFn() instanceof GlobalWindows)\n        && !outputStrategy.isAllowedLatenessSpecified()) {\n      throw new IllegalArgumentException(\n          \"Except when using GlobalWindows,\"\n              + \" calling .triggering() to specify a trigger requires that the allowed lateness\"\n              + \" be specified using .withAllowedLateness() to set the upper bound on how late\"\n              + \" data can arrive before being dropped. See Javadoc for more details.\");\n    }\n\n    if (!outputStrategy.isModeSpecified() && canProduceMultiplePanes(outputStrategy)) {\n      throw new IllegalArgumentException(\n          \"Calling .triggering() to specify a trigger or calling .withAllowedLateness() to\"\n              + \" specify an allowed lateness greater than zero requires that the accumulation\"\n              + \" mode be specified using .discardingFiredPanes() or .accumulatingFiredPanes().\"\n              + \" See Javadoc for more details.\");\n    }\n  }\n\n  private boolean canProduceMultiplePanes(WindowingStrategy<?, ?> strategy) {\n    // The default trigger is Repeatedly.forever(AfterWatermark.pastEndOfWindow()); This fires\n    // for every late-arriving element if allowed lateness is nonzero, and thus we must have\n    // an accumulating mode specified\n    boolean dataCanArriveLate =\n        !(strategy.getWindowFn() instanceof GlobalWindows)\n            && strategy.getAllowedLateness().getMillis() > 0;\n    boolean hasCustomTrigger = !(strategy.getTrigger() instanceof DefaultTrigger);\n    return dataCanArriveLate || hasCustomTrigger;\n  }\n","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Window.java#L350-L386","documentation":"When a windowing strategy can emit multiple panes per window (custom trigger or nonzero allowed lateness), Beam requires the accumulation mode to be stated explicitly. Window.applicableTo() throws IllegalArgumentException if the mode is unspecified, because the pipeline would otherwise be ambiguous about whether later panes accumulate or discard prior results.","triggerScenarios":"Calling Window.into(fn).triggering(...) or .withAllowedLateness(greater than zero) without calling .discardingFiredPanes() or .accumulatingFiredPanes(), so canProduceMultiplePanes(strategy) is true and isModeSpecified() is false.","commonSituations":"Adding triggers or allowed lateness to an existing windowed pipeline but forgetting to pick an accumulation mode; upgrading Beam where stricter validation now catches previously silent ambiguity; following snippets that omitted the mode.","solutions":["Append .discardingFiredPanes() if each pane should contain only the new elements since the last firing.","Append .accumulatingFiredPanes() if each pane should contain all elements accumulated so far.","Remove .triggering()/.withAllowedLateness() if single-panes-per-window is actually desired (DefaultTrigger with zero lateness needs no mode)."],"exampleFix":"// before\nPCollection<T> out = items.apply(Window.<T>into(FixedWindows.of(StandardMinutes.of(1)))\n    .triggering(AfterWatermark.pastEndOfWindow())\n    .withAllowedLateness(StandardMinutes.of(1)));\n// after\nPCollection<T> out = items.apply(Window.<T>into(FixedWindows.of(StandardMinutes.of(1)))\n    .triggering(AfterWatermark.pastEndOfWindow())\n    .withAllowedLateness(StandardMinutes.of(1))\n    .accumulatingFiredPanes());","handlingStrategy":"validation","validationCode":"if ((trigger != null && !(trigger instanceof DefaultTrigger)) || (allowedLateness != null && allowedLateness.isLongerThan(Duration.ZERO))) {\n  if (!discardingFiredPanes && !accumulatingFiredPanes) {\n    throw new IllegalArgumentException(\"specify .discardingFiredPanes() or .accumulatingFiredPanes()\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whenever you add a trigger or lateness, decide the accumulation mode at the same time.","Prefer .accumulatingFiredPanes() for correctness-checked pipelines and .discardingFiredPanes() for efficiency, documenting the choice.","Keep windowing configuration in one helper method so mode and trigger cannot drift apart."],"tags":["java","apache-beam","windowing","triggers","pipeline-construction"],"backgroundTag":"missing-required-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}