{"record":{"id":"0b6210ae8b0c36aa","repo":"apache/beam","slug":"s-for-s-with-urn-s-did-not-contain-expected-proto-message","errorCode":null,"errorMessage":"%s for %s with URN %s did not contain expected proto message for payload","messagePattern":"(.+?) for (.+?) with URN (.+?) did not contain expected proto message for payload","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/WindowingStrategyTranslation.java","lineNumber":392,"sourceCode":"            SlidingWindowsPayload.parseFrom(windowFnSpec.getPayload());\n        return SlidingWindows.of(Duration.millis(Durations.toMillis(slidingParams.getSize())))\n            .every(Duration.millis(Durations.toMillis(slidingParams.getPeriod())))\n            .withOffset(Duration.millis(Timestamps.toMillis(slidingParams.getOffset())));\n      } else if (s.equals(getUrn(SessionWindowsPayload.Enum.PROPERTIES))) {\n        SessionWindowsPayload sessionParams =\n            SessionWindowsPayload.parseFrom(windowFnSpec.getPayload());\n        return Sessions.withGapDuration(\n            Duration.millis(Durations.toMillis(sessionParams.getGapSize())));\n      } else if (s.equals(SERIALIZED_JAVA_WINDOWFN_URN)) {\n        return (WindowFn<?, ?>)\n            SerializableUtils.deserializeFromByteArray(\n                windowFnSpec.getPayload().toByteArray(), \"WindowFn\");\n      } else {\n        throw new IllegalArgumentException(\n            \"Unknown or unsupported WindowFn: \" + windowFnSpec.getUrn());\n      }\n    } catch (InvalidProtocolBufferException e) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"%s for %s with URN %s did not contain expected proto message for payload\",\n              FunctionSpec.class.getSimpleName(),\n              WindowFn.class.getSimpleName(),\n              windowFnSpec.getUrn()),\n          e);\n    }\n  }\n}\n","sourceCodeStart":374,"sourceCodeEnd":402,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/WindowingStrategyTranslation.java#L374-L402","documentation":"Thrown by WindowingStrategyTranslation.windowFnFromProto when the serialized Java WindowFn payload cannot be parsed as the expected proto/message (InvalidProtocolBufferException). The FunctionSpec claims to contain a serialized WindowFn but its payload bytes do not deserialize correctly.","triggerScenarios":"Calling windowFnFromProto on a FunctionSpec with a truncated, corrupted, or wrong-type payload (payload not produced by SerializableUtils/FunctionSpec serialization).","commonSituations":"Pipeline protos damaged in transit or storage; payload bytes overwritten by a different message type; version skew where the payload encoding changed between Beam releases.","solutions":["Re-serialize the pipeline / window function from a trusted source instead of reusing the corrupted proto.","Check that the FunctionSpec payload was created by the matching serializer (FunctionSpecs.serializeJavaWindowFn) and not hand-built.","Verify the proto was not truncated during transport (e.g. length-prefixed framing issues in gRPC/job-server).","Ensure the serializable WindowFn class exists and its serialVersionUID/shape is compatible on the reading side."],"exampleFix":"// before\nFunctionSpec bad = FunctionSpec.newBuilder().setUrn(SERIALIZED_JAVA_WINDOWFN_URN)\n    .setPayload(BytesValue.of(ByteString.copyFrom(badBytes))).build();\n// after\nFunctionSpec ok = FunctionSpecs.serializeJavaWindowFn(windowFn);","handlingStrategy":"try-catch","validationCode":"try { SerializableUtils.deserializeFromByteArray(spec.getPayload().toByteArray(), \"WindowFn\"); } catch (Exception e) { throw new IllegalArgumentException(\"WindowFn payload is not a valid serialized object\", e); }","typeGuard":"boolean hasNonEmptyPayload(RunnerApi.FunctionSpec spec) { return spec != null && spec.getPayload() != null && !spec.getPayload().isEmpty(); }","tryCatchPattern":"try { wf = WindowingStrategyTranslation.windowFn(strategyProto); } catch (IllegalArgumentException e) { if (e.getCause() instanceof InvalidProtocolBufferException) { /* re-serialize pipeline from source */ } throw e; }","preventionTips":["Build FunctionSpec payloads only via the official serializer helpers","Avoid storing/transmitting protos without proper length framing","Re-serialize rather than persisting protos across Beam upgrades"],"tags":["java","beam","proto","deserialization","corrupt-payload"],"backgroundTag":"protobuf-unmarshal-failed","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"}