{"record":{"id":"a6abd99f8796bfa2","repo":"apache/beam","slug":"unsupported-payload-type-record-getpayloadtype","errorCode":null,"errorMessage":"Unsupported payload type: ${record.getPayloadType()}","messagePattern":"Unsupported payload type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/data/Solace.java","lineNumber":550,"sourceCode":"    private static BytesXMLMessage encodePayload(Record record) {\n      switch (record.getPayloadType()) {\n        case TEXT:\n          TextMessage text = JCSMPFactory.onlyInstance().createMessage(TextMessage.class);\n          text.setText(record.getText());\n          return text;\n        case BYTES:\n          BytesMessage bytes = JCSMPFactory.onlyInstance().createMessage(BytesMessage.class);\n          bytes.setData(record.getPayload());\n          return bytes;\n        case BYTES_XML:\n          BytesXMLMessage xml = JCSMPFactory.onlyInstance().createBytesXMLMessage();\n          xml.writeBytes(record.getPayload());\n          if (record.getAttachmentBytes().length != 0) {\n            xml.writeAttachment(record.getAttachmentBytes());\n          }\n          return xml;\n        default:\n          throw new IllegalArgumentException(\n              \"Unsupported payload type: \" + record.getPayloadType());\n      }\n    }\n\n    /**\n     * Reads the payload from a {@link BytesXMLMessage} into a partially-populated {@link\n     * Record.Builder}.\n     *\n     * @param msg the JCSMP message.\n     * @return a {@link Record.Builder} with the payload and payload type set based on the message\n     *     type.\n     */\n    private static Record.Builder decodePayload(@NonNull BytesXMLMessage msg) {\n      if (msg instanceof TextMessage) {\n        String text = ((TextMessage) msg).getText();\n        byte[] payload = text == null ? new byte[0] : text.getBytes(StandardCharsets.UTF_8);\n        return Record.builder().setPayloadType(Record.PayloadType.TEXT).setPayload(payload);\n      }","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/data/Solace.java#L532-L568","documentation":"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.","triggerScenarios":"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.).","commonSituations":"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.","solutions":["Explicitly set the payload type when building the record: `Solace.Record.builder().setPayloadType(PayloadType.TEXT)...` (or BINARY).","Inspect the offending record's payloadType — log it before writing to spot null/unknown values.","If records come from an upstream source, map unknown types to BINARY with raw payload bytes.","Upgrade the connector if the payload type was added in a newer Solace SDK/enum version than your Beam connector supports."],"exampleFix":"// before\nSolace.Record record = Solace.Record.builder().setPayload(bytes).build(); // payloadType unset\n// after\nSolace.Record record = Solace.Record.builder()\n    .setPayload(bytes)\n    .setPayloadType(PayloadType.BINARY)\n    .build();","handlingStrategy":"validation","validationCode":"if (record.getPayloadType() == null) {\n  throw new IllegalArgumentException(\"Record payloadType must be set (TEXT or BINARY) before writing\");\n}","typeGuard":"boolean isWritable(Solace.Record r) { return r.getPayloadType() == PayloadType.TEXT || r.getPayloadType() == PayloadType.BINARY; }","tryCatchPattern":"try { write(records); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported payload type\")) { /* log payloadType and fix record construction */ } throw e; }","preventionTips":["Always call setPayloadType in record builders","Map unknown upstream types to BINARY","Log payloadType when constructing records in custom pipelines"],"tags":["solace","java","payload-type","enum","write"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}