apache/beam · error · java.lang.RuntimeException
Unable to encode constant members of ParamWindowedValueCoder
Error message
Unable to encode constant members of ParamWindowedValueCoder:
What it means
ParamWindowedValueCoder encodes its constant members (timestamp, windows, pane info, value kind) to a byte payload during serialization; if FullWindowedValueCoder.encode() throws IOException it is rethrown as a RuntimeException with this message. It signals the sample windowed value could not be serialized while constructing the coder.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValues.java:1456
// ParamWindowedValueCoder
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WindowedValue<byte[]> windowedValue =
WindowedValues.of(
EMPTY_BYTES,
from.getTimestamp(),
from.getWindows(),
from.getPaneInfo(),
null,
null,
CausedByDrain.NORMAL,
null,
from.getValueKind());
WindowedValues.FullWindowedValueCoder<byte[]> windowedValueCoder =
WindowedValues.FullWindowedValueCoder.of(ByteArrayCoder.of(), from.getWindowCoder());
try {
windowedValueCoder.encode(windowedValue, baos);
} catch (IOException e) {
throw new RuntimeException(
"Unable to encode constant members of ParamWindowedValueCoder: ", e);
}
return baos.toByteArray();
}
/** Create a {@link Coder} from its component {@link Coder coders}. */
public static WindowedValues.ParamWindowedValueCoder<?> fromComponents(
List<Coder<?>> components, byte[] payload) {
Coder<? extends BoundedWindow> windowCoder =
(Coder<? extends BoundedWindow>) components.get(1);
WindowedValues.FullWindowedValueCoder<byte[]> windowedValueCoder =
WindowedValues.FullWindowedValueCoder.of(ByteArrayCoder.of(), windowCoder);
try {
ByteArrayInputStream bais = new ByteArrayInputStream(payload);
WindowedValue<byte[]> windowedValue = windowedValueCoder.decode(bais);
return WindowedValues.ParamWindowedValueCoder.of(
components.get(0),View on GitHub (pinned to 12126d8942)
Solutions
- Check the 'Caused by' IOException to see which component coder failed
- Ensure the window Coder can serialize all custom windows used
- Verify the value's coder is registered and stable across job submission and workers
- Keep Beam SDK versions identical between submitter and expansion/worker environments
Example fix
// before: custom window without registered coder MyCustomWindow w = new MyCustomWindow(...); // after: provide a custom window coder pipeline.getCoderRegistry().registerCoderForClass(MyCustomWindow.class, MyCustomWindowCoder.of());
Defensive patterns
Strategy: validation
Validate before calling
Coder<T> coder = pipeline.getCoderRegistry().getCoder(valueType);
if (coder == null) throw new IllegalStateException("No registered coder for " + valueType); Try / catch
try { ParamWindowedValueCoder.of(...); } catch (RuntimeException e) { if (e.getCause() instanceof IOException) { /* coder encoding failure: fix component coder */ } throw e; } Prevention
- Register coders for all custom window and value types
- Test coder round-trips (encode then decode) in unit tests
- Keep Beam versions consistent across environments
When it happens
Trigger: Constructing a ParamWindowedValueCoder (e.g., via its constructor from an existing WindowedValue) where windowedValueCoder.encode(windowedValue, baos) fails with IOException, usually because the value or window coder cannot serialize the given element.
Common situations: Custom window types without a proper Coder; values with non-serializable fields when Java serialization crosses worker boundaries; mismatched coder versions after a Beam upgrade.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- cannot encode a null String
- cannot encode a null Integer
- cannot encode a null ValueKind
- {errorContext}: unable to encode value {value} using {coder}
- Unable to decode constant members from payload for ParamWind
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/55b9316c3150ccc3.
Report an issue: GitHub.