{"record":{"id":"a76b32dfff08971c","repo":"apache/beam","slug":"expected-a-s-with-components-but-received-s","errorCode":null,"errorMessage":"Expected a %s with components but received %s","messagePattern":"Expected a (.+?) with components but received (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/WindowingStrategyTranslation.java","lineNumber":328,"sourceCode":"            .setWindowCoderId(components.registerCoder(windowFn.windowCoder()))\n            .setEnvironmentId(environmentId);\n\n    return windowingStrategyProto.build();\n  }\n\n  /**\n   * Converts from a {@link RunnerApi.WindowingStrategy} accompanied by {@link Components} to the\n   * SDK's {@link WindowingStrategy}.\n   */\n  public static WindowingStrategy<?, ?> fromProto(RunnerApi.MessageWithComponents proto)\n      throws InvalidProtocolBufferException {\n    switch (proto.getRootCase()) {\n      case WINDOWING_STRATEGY:\n        return fromProto(\n            proto.getWindowingStrategy(),\n            RehydratedComponents.forComponents(proto.getComponents()));\n      default:\n        throw new IllegalArgumentException(\n            String.format(\n                \"Expected a %s with components but received %s\",\n                RunnerApi.WindowingStrategy.class.getCanonicalName(), proto));\n    }\n  }\n\n  /**\n   * Converts from {@link RunnerApi.WindowingStrategy} to the SDK's {@link WindowingStrategy} using\n   * the provided components to dereferences identifiers found in the proto.\n   */\n  public static WindowingStrategy<?, ?> fromProto(\n      RunnerApi.WindowingStrategy proto, RehydratedComponents components)\n      throws InvalidProtocolBufferException {\n\n    FunctionSpec windowFnSpec = proto.getWindowFn();\n    WindowFn<?, ?> windowFn = windowFnFromProto(windowFnSpec);\n    TimestampCombiner timestampCombiner = timestampCombinerFromProto(proto.getOutputTime());\n    AccumulationMode accumulationMode = fromProto(proto.getAccumulationMode());","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/WindowingStrategyTranslation.java#L310-L346","documentation":"Thrown by the top-level WindowingStrategyTranslation.fromProto(MessageWithComponents) overload when the incoming message's oneof root is not the WINDOWING_STRATEGY case. The method expects a message that bundles a WindowingStrategy with its Components so PCollections can be rehydrated; receiving any other root case means the caller passed the wrong wrapper type.","triggerScenarios":"Calling fromProto(proto) where proto.getRootCase() is not WINDOWING_STRATEGY — e.g. passing a bare components message, an empty/incorrectly built MessageWithComponents, or a message from a different oneof union.","commonSituations":"Hand-constructing pipeline protos in tests; runner code that mis-assembles the oneof field; decoding a proto that was never populated because serialization failed upstream.","solutions":["Ensure the message was built with WINDOWING_STRATEGY set together with its components (use fromProto(windowingStrategy, components) output as input).","Check that the serialization/deserialization pair populates the same oneof case.","Call the two-argument fromProto(WindowingStrategy, RehydratedComponents) directly if you already have the pieces.","Log/inspect proto.getRootCase() and getAllFields() to confirm what was actually received."],"exampleFix":"// before\nWindowingStrategy<?> ws = WindowingStrategyTranslation.fromProto(bareStrategyProto);\n// after\nWindowingStrategy<?> ws = WindowingStrategyTranslation.fromProto(\n    MessageWithComponents.ofWindowingStrategy(strategyProto, componentsProto));","handlingStrategy":"validation","validationCode":"if (proto == null || proto.getRootCase() != RunnerApi.MessageWithComponents.RootCase.WINDOWING_STRATEGY) throw new IllegalArgumentException(\"Expected MessageWithComponents with WINDOWING_STRATEGY root\");","typeGuard":"boolean hasWindowingStrategyRoot(RunnerApi.MessageWithComponents m) { return m != null && m.getRootCase() == RunnerApi.MessageWithComponents.RootCase.WINDOWING_STRATEGY; }","tryCatchPattern":"try { ws = WindowingStrategyTranslation.fromProto(messageWithComponents); } catch (IllegalArgumentException e) { log.error(\"Wrong root case {}; use the (WindowingStrategy, RehydratedComponents) overload\", messageWithComponents.getRootCase(), e); throw e; }","preventionTips":["Round-trip protos through the official toProto/fromProto pairs instead of hand-building messages","Check getRootCase() after deserialization to detect unpopulated oneofs","Use MessageWithComponents factory helpers when bundling strategy + components"],"tags":["java","beam","proto","oneof","decoding"],"backgroundTag":"unexpected-response-shape","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"}