{"record":{"id":"5434ac72ebf785b2","repo":"apache/beam","slug":"fn-getincompatibleglobalwindowerrormessage","errorCode":null,"errorMessage":"fn.getIncompatibleGlobalWindowErrorMessage()","messagePattern":"fn\\.getIncompatibleGlobalWindowErrorMessage\\(\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Combine.java","lineNumber":1213,"sourceCode":"              .setCoder(KvCoder.of(VoidCoder.of(), input.getCoder()));\n\n      Combine.PerKey<Void, InputT, OutputT> combine = Combine.fewKeys(fn, fnDisplayData);\n      if (!sideInputs.isEmpty()) {\n        combine = combine.withSideInputs(sideInputs);\n      }\n\n      PCollection<KV<Void, OutputT>> combined;\n      if (fanout >= 2) {\n        combined = withKeys.apply(combine.withHotKeyFanout(fanout));\n      } else {\n        combined = withKeys.apply(combine);\n      }\n\n      PCollection<OutputT> output = combined.apply(Values.create());\n\n      if (insertDefault) {\n        if (!output.getWindowingStrategy().getWindowFn().isCompatible(new GlobalWindows())) {\n          throw new IllegalStateException(fn.getIncompatibleGlobalWindowErrorMessage());\n        }\n        return insertDefaultValueIfEmpty(output);\n      } else {\n        return output;\n      }\n    }\n\n    @Override\n    public void populateDisplayData(DisplayData.Builder builder) {\n      super.populateDisplayData(builder);\n\n      Combine.populateDisplayData(builder, fn, fnDisplayData);\n      Combine.populateGlobalDisplayData(builder, fanout, insertDefault);\n    }\n\n    private PCollection<OutputT> insertDefaultValueIfEmpty(PCollection<OutputT> maybeEmpty) {\n      final PCollectionView<Iterable<OutputT>> maybeEmptyView = maybeEmpty.apply(View.asIterable());\n","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Combine.java#L1195-L1231","documentation":"Combine.globally/related transforms insert a default value for empty PCollections only if the output's windowing is compatible with GlobalWindows; otherwise the default's meaning is undefined and an IllegalStateException with the fn's incompatible-global-window message is thrown.","triggerScenarios":"Calling Combine.globally(fn).withoutDefaults(false) (default insertion enabled) on a PCollection windowed with a non-global WindowFn (e.g. FixedWindows/SlidingWindows) — the fn must be windowing-safe to default.","commonSituations":"Combining a windowed stream without .withoutDefaults(); forgetting to add .withDefaultWorldWindowFn or trigger/windowing adjustments; a custom CombineFn whose getIncompatibleGlobalWindowErrorMessage names the incompatibility.","solutions":["Call .withoutDefaults() so no default is inserted for empty windowed inputs","Use .withHotKeyFanout-safe alternatives or re-window to GlobalWindows before combining if a global default is truly needed","Provide an explicit default via .withDefault... style APIs where available"],"exampleFix":"// before\npc.apply(Combine.globally(myFn)) // windowed input\n// after\npc.apply(Combine.globally(myFn).withoutDefaults())","handlingStrategy":"validation","validationCode":"boolean safeForDefault = pc.getWindowingStrategy().getWindowFn().isCompatible(new GlobalWindows());\nif (!safeForDefault) needWithoutDefaults = true;","typeGuard":null,"tryCatchPattern":"try {\n  return pc.apply(Combine.globally(fn));\n} catch (IllegalStateException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"window\")) {\n    return pc.apply(Combine.globally(fn).withoutDefaults());\n  }\n  throw e;\n}","preventionTips":["Call .withoutDefaults() whenever combining windowed PCollections","Re-window to GlobalWindows explicitly if a global default is required","Keep windowing strategy in mind when designing custom CombineFns and their error messages"],"tags":["java","windowing","combine"],"backgroundTag":"incompatible-windowing-strategy","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"}