{"record":{"id":"f1b327f177256492","repo":"apache/beam","slug":"can-t-make-unserializable-value-s-a-serializable-value-which","errorCode":null,"errorMessage":"Can't make unserializable value %s a serializable value (which is mandatory for Apache Beam dataflow implementation)","messagePattern":"Can't make unserializable value (.+?) a serializable value \\(which is mandatory for Apache Beam dataflow implementation\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/rabbitmq/src/main/java/org/apache/beam/sdk/io/rabbitmq/RabbitMqMessage.java","lineNumber":109,"sourceCode":"          value = getTransformedValue(value);\n        }\n        returned.put(h.getKey(), value);\n      }\n    }\n    return returned;\n  }\n\n  private static Object getTransformedValue(Object value) {\n    try {\n      if (value instanceof LongString) {\n        LongString longString = (LongString) value;\n        byte[] bytes = longString.getBytes();\n        value = new String(bytes, StandardCharsets.UTF_8);\n      } else {\n        throw new RuntimeException(String.format(\"No transformation defined for %s\", value));\n      }\n    } catch (Throwable t) {\n      throw new UnsupportedOperationException(\n          String.format(\n              \"Can't make unserializable value %s a serializable value (which is mandatory for Apache Beam dataflow implementation)\",\n              value),\n          t);\n    }\n    return value;\n  }\n\n  private final @Nullable String routingKey;\n  private final byte[] body;\n  private final String contentType;\n  private final String contentEncoding;\n  private final Map<String, Object> headers;\n  private final Integer deliveryMode;\n  private final Integer priority;\n  private final @Nullable String correlationId;\n  private final @Nullable String replyTo;\n  private final String expiration;","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/rabbitmq/src/main/java/org/apache/beam/sdk/io/rabbitmq/RabbitMqMessage.java#L91-L127","documentation":"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).","triggerScenarios":"Consuming a message whose headers contain types other than LongString; the conversion throws and is caught and rethrown here during serializableHeaders().","commonSituations":"Same as 2445: producers emitting typed AMQP header values (numbers, booleans, nested tables) that Beam cannot carry through the pipeline.","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."],"exampleFix":"// before\nprops = builder.build(\"x-info\", true); // Boolean header -> UnsupportedOperationException\n// after\nprops = builder.build(\"x-info\", new LongStringHelper.LongString(\"true\".getBytes(StandardCharsets.UTF_8)));","handlingStrategy":"try-catch","validationCode":"// Same pre-check as 2445: only LongString values survive serialization\nfor (Map.Entry<String, Object> h : headers.entrySet()) {\n  if (!(h.getValue() instanceof LongString)) { /* sanitize or drop before read */ }\n}","typeGuard":"boolean isBeamSerializable(Object v) { return v instanceof LongString || v instanceof String; }","tryCatchPattern":"try { serializableHeaders(); } catch (UnsupportedOperationException e) { log.error(\"non-serializable header: {}\", e.getMessage()); /* drop message or convert headers upstream */ }","preventionTips":["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."],"tags":["rabbitmq","serialization","headers","apache-beam"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}