apache/beam · error · UnsupportedOperationException
Can't make unserializable value %s a serializable value (whi
Error message
Can't make unserializable value %s a serializable value (which is mandatory for Apache Beam dataflow implementation)
What it means
This is the wrapper for error 2445: when getTransformedValue fails to convert a RabbitMQ header value into a Java-serializable object, it catches the Throwable and throws an UnsupportedOperationException saying the value cannot be made serializable, which is mandatory for Beam dataflow (all PCollection elements must be serializable).
Source
Thrown at sdks/java/io/rabbitmq/src/main/java/org/apache/beam/sdk/io/rabbitmq/RabbitMqMessage.java:109
value = getTransformedValue(value);
}
returned.put(h.getKey(), value);
}
}
return returned;
}
private static Object getTransformedValue(Object value) {
try {
if (value instanceof LongString) {
LongString longString = (LongString) value;
byte[] bytes = longString.getBytes();
value = new String(bytes, StandardCharsets.UTF_8);
} else {
throw new RuntimeException(String.format("No transformation defined for %s", value));
}
} catch (Throwable t) {
throw new UnsupportedOperationException(
String.format(
"Can't make unserializable value %s a serializable value (which is mandatory for Apache Beam dataflow implementation)",
value),
t);
}
return value;
}
private final @Nullable String routingKey;
private final byte[] body;
private final String contentType;
private final String contentEncoding;
private final Map<String, Object> headers;
private final Integer deliveryMode;
private final Integer priority;
private final @Nullable String correlationId;
private final @Nullable String replyTo;
private final String expiration;View on GitHub (pinned to 12126d8942)
Solutions
- Publish header values only as strings/LongString from the producer.
- Strip or rewrite non-serializable headers at an intermediary (e.g. a consumer-side pre-processing step).
- Patch RabbitMqMessage to convert additional types to String or byte[] before returning.
- Keep message metadata in the body with a schema Beam can serialize.
Example fix
// before
props = builder.build("x-info", true); // Boolean header -> UnsupportedOperationException
// after
props = builder.build("x-info", new LongStringHelper.LongString("true".getBytes(StandardCharsets.UTF_8))); Defensive patterns
Strategy: try-catch
Validate before calling
// Same pre-check as 2445: only LongString values survive serialization
for (Map.Entry<String, Object> h : headers.entrySet()) {
if (!(h.getValue() instanceof LongString)) { /* sanitize or drop before read */ }
} Type guard
boolean isBeamSerializable(Object v) { return v instanceof LongString || v instanceof String; } Try / catch
try { serializableHeaders(); } catch (UnsupportedOperationException e) { log.error("non-serializable header: {}", e.getMessage()); /* drop message or convert headers upstream */ } Prevention
- Restrict RabbitMQ header usage to UTF-8 strings in your messaging conventions.
- Document the serializability requirement for all producing teams.
- Convert complex metadata to a JSON string in a single header.
When it happens
Trigger: Consuming a message whose headers contain types other than LongString; the conversion throws and is caught and rethrown here during serializableHeaders().
Common situations: Same as 2445: producers emitting typed AMQP header values (numbers, booleans, nested tables) that Beam cannot carry through the pipeline.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- No transformation defined for %s
- cannot encode a null Integer
- cannot encode a null Long
- cannot encode a null Short
- cannot encode a null BitSet
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/f1b327f177256492.
Report an issue: GitHub.