{"record":{"id":"d41f1876d41478db","repo":"apache/beam","slug":"serializable-row-does-not-exist-for-payload-of-type-s","errorCode":null,"errorMessage":"serializable Row does not exist for payload of type: %s","messagePattern":"serializable Row does not exist for payload of type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubRowToMessage.java","lineNumber":526,"sourceCode":"        return checkArgumentNotNull(\n            row.getBytes(payloadKeyName), \"Payload field '%s' cannot be null\", payloadKeyName);\n      }\n      return checkStateNotNull(payloadSerializer).serialize(serializableRow(row));\n    }\n\n    /**\n     * Extracts the serializable part of a {@link Row} from the following mutually exclusive\n     * sources. <br>\n     * - serialized {@link #payloadKeyName} {@link Field} with {@link TypeName#ROW} using the {@link\n     * #payloadSerializer} <br>\n     * - serialized user fields provided that are not {@link #attributesKeyName} and {@link\n     * #sourceTimestampKeyName}\n     */\n    Row serializableRow(Row row) {\n      SchemaReflection schemaReflection = SchemaReflection.of(row.getSchema());\n\n      if (schemaReflection.matchesAll(FieldMatcher.of(payloadKeyName, PAYLOAD_BYTES_TYPE_NAME))) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"serializable Row does not exist for payload of type: %s\",\n                PAYLOAD_BYTES_TYPE_NAME));\n      }\n\n      if (schemaReflection.matchesAll(FieldMatcher.of(payloadKeyName, PAYLOAD_ROW_TYPE_NAME))) {\n        return checkArgumentNotNull(\n            row.getRow(payloadKeyName), \"Payload field '%s' cannot be null\", payloadKeyName);\n      }\n      Schema withUserFieldsOnly =\n          removeFields(row.getSchema(), attributesKeyName, sourceTimestampKeyName);\n      Map<String, Object> values = new HashMap<>();\n      for (String name : withUserFieldsOnly.getFieldNames()) {\n        values.put(name, row.getValue(name));\n      }\n      return Row.withSchema(withUserFieldsOnly).withFieldValues(values).build();\n    }\n  }","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PubsubRowToMessage.java#L508-L544","documentation":"In PubsubRowToMessage's DoFn, serializableRow() converts a Row's payload field into a serializable Row representation. If the payload field is of the BYTES type (PAYLOAD_BYTES_TYPE_NAME), no serializable Row exists for it, so it throws an IllegalArgumentException.","triggerScenarios":"Processing a Row whose payload field (named per payloadKeyName) is declared as BYTES in the schema, causing schemaReflection.matchesAll(FieldMatcher.of(payloadKeyName, PAYLOAD_BYTES_TYPE_NAME)) to be true during message conversion.","commonSituations":"Schemas where the payload was declared as bytes (raw payload) but the Row-to-Message transform expects a structured ROW-typed payload; schema drift between pipeline stages; switching from RAW format to structured format without changing the schema.","solutions":["Change the payload field's type in the schema from BYTES to a ROW type that serializableRow() can convert.","If the payload is genuinely raw bytes, use a pipeline path that supports byte payloads (e.g. RAW format) instead of PubsubRowToMessage.","Decode/parse the bytes into a Row upstream so the payload field arrives as a structured Row."],"exampleFix":"// before\nSchema schema = Schema.builder().addByteArrayField(\"payload\").build();\n// after\nSchema schema = Schema.builder().addRowField(\"payload\", Schema.builder().addStringField(\"key\").build()).build();","handlingStrategy":"validation","validationCode":"Schema.Field payload = row.getSchema().getField(payloadKeyName);\nif (payload != null && payload.getType().getTypeName().equals(org.apache.beam.sdk.schemas.Schema.TypeName.BYTES)) { throw new IllegalArgumentException(\"payload must be ROW, not BYTES, for PubsubRowToMessage\"); }","typeGuard":"boolean payloadIsRow(org.apache.beam.sdk.values.Row row, String name) { Schema.Field f = row.getSchema().getField(name); return f != null && f.getType().getTypeName() == org.apache.beam.sdk.schemas.Schema.TypeName.ROW; }","tryCatchPattern":"try { rowToMessage.expand(input); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"serializable Row does not exist\")) { /* change payload field type to ROW */ } throw e; }","preventionTips":["Declare the payload field as a ROW type when using Row-to-Message conversion; reserve BYTES for the RAW path.","Check payload field types at pipeline construction time, not at runtime in the DoFn."],"tags":["java","apache-beam","pubsub","schema","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}