apache/beam · error · IllegalArgumentException

Unsupported payload type

Error message

Unsupported payload type: ${record.getPayloadType()}

What it means

Solace's msg()/encodePayload switch throws this IllegalArgumentException when a record has a PayloadType the connector doesn't know how to encode into a JCSMP message. The default branch fires for null or unrecognized payload types, meaning the record cannot be converted for publishing.

Solutions

  1. Explicitly set the payload type when building the record: `Solace.Record.builder().setPayloadType(PayloadType.TEXT)...` (or BINARY).
  2. Inspect the offending record's payloadType — log it before writing to spot null/unknown values.
  3. If records come from an upstream source, map unknown types to BINARY with raw payload bytes.
  4. Upgrade the connector if the payload type was added in a newer Solace SDK/enum version than your Beam connector supports.

Example fix

// before
Solace.Record record = Solace.Record.builder().setPayload(bytes).build(); // payloadType unset
// after
Solace.Record record = Solace.Record.builder()
    .setPayload(bytes)
    .setPayloadType(PayloadType.BINARY)
    .build();
Defensive patterns

Strategy: validation

Validate before calling

if (record.getPayloadType() == null) {
  throw new IllegalArgumentException("Record payloadType must be set (TEXT or BINARY) before writing");
}

Type guard

boolean isWritable(Solace.Record r) { return r.getPayloadType() == PayloadType.TEXT || r.getPayloadType() == PayloadType.BINARY; }

Try / catch

try { write(records); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported payload type")) { /* log payloadType and fix record construction */ } throw e; }

Prevention

When it happens

Trigger: Building a Solace.Record without calling setPayloadType (leaving it null or unset) before passing it to SolaceIO.Write; constructing a Record with a PayloadType value outside the enum cases handled (TEXT, BINARY, etc.).

Common situations: Programmatically assembled Records where the builder's payload-type field was forgotten; deserialized records from another pipeline version with an unknown/legacy type; hand-rolled record construction instead of using the Write transform's mapping functions.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/a6abd99f8796bfa2. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/data/Solace.java:550

    private static BytesXMLMessage encodePayload(Record record) {
      switch (record.getPayloadType()) {
        case TEXT:
          TextMessage text = JCSMPFactory.onlyInstance().createMessage(TextMessage.class);
          text.setText(record.getText());
          return text;
        case BYTES:
          BytesMessage bytes = JCSMPFactory.onlyInstance().createMessage(BytesMessage.class);
          bytes.setData(record.getPayload());
          return bytes;
        case BYTES_XML:
          BytesXMLMessage xml = JCSMPFactory.onlyInstance().createBytesXMLMessage();
          xml.writeBytes(record.getPayload());
          if (record.getAttachmentBytes().length != 0) {
            xml.writeAttachment(record.getAttachmentBytes());
          }
          return xml;
        default:
          throw new IllegalArgumentException(
              "Unsupported payload type: " + record.getPayloadType());
      }
    }

    /**
     * Reads the payload from a {@link BytesXMLMessage} into a partially-populated {@link
     * Record.Builder}.
     *
     * @param msg the JCSMP message.
     * @return a {@link Record.Builder} with the payload and payload type set based on the message
     *     type.
     */
    private static Record.Builder decodePayload(@NonNull BytesXMLMessage msg) {
      if (msg instanceof TextMessage) {
        String text = ((TextMessage) msg).getText();
        byte[] payload = text == null ? new byte[0] : text.getBytes(StandardCharsets.UTF_8);
        return Record.builder().setPayloadType(Record.PayloadType.TEXT).setPayload(payload);
      }

View on GitHub (pinned to 12126d8942)