{"record":{"id":"e1d1d623a79981b4","repo":"apache/beam","slug":"improper-schema-for-beam-record-s-has-no-row-schema-to-build","errorCode":null,"errorMessage":"Improper schema for Beam record: %s has no row schema to build a Row from.","messagePattern":"Improper schema for Beam record: (.+?) has no row schema to build a Row from\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaConnectUtils.java","lineNumber":124,"sourceCode":"    return new SourceRecordMapper<Row>() {\n      @Override\n      public Row mapSourceRecord(SourceRecord sourceRecord) throws Exception {\n        return beamRowFromKafkaStruct((Struct) sourceRecord.value(), recordSchema);\n      }\n\n      private Row beamRowFromKafkaStruct(Struct kafkaStruct, Schema beamSchema) {\n        Row.Builder rowBuilder = Row.withSchema(beamSchema);\n        for (Schema.Field f : beamSchema.getFields()) {\n          Object structField = kafkaStruct.getWithoutDefault(f.getName());\n          switch (kafkaStruct.schema().field(f.getName()).schema().type()) {\n            case ARRAY:\n            case MAP:\n              // TODO(pabloem): Handle nested structs\n              throw new IllegalArgumentException(\"UNABLE TO CONVERT FIELD \" + f);\n            case STRUCT:\n              Schema fieldSchema = f.getType().getRowSchema();\n              if (fieldSchema == null) {\n                throw new IllegalArgumentException(\n                    String.format(\n                        \"Improper schema for Beam record: %s has no row schema to build a Row from.\",\n                        f.getName()));\n              }\n              if (structField == null) {\n                // If the field is null, then we must add a null field to ensure we encode things\n                // properly.\n                rowBuilder = rowBuilder.addValue(null);\n                break;\n              }\n              rowBuilder =\n                  rowBuilder.addValue(beamRowFromKafkaStruct((Struct) structField, fieldSchema));\n              break;\n            default:\n              rowBuilder = rowBuilder.addValue(structField);\n              break;\n          }\n        }","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/KafkaConnectUtils.java#L106-L142","documentation":"When converting a STRUCT-typed field, beamRowFromKafkaStruct needs the Beam FieldType's row schema to build the nested Row. If f.getType().getRowSchema() returns null the Beam field was declared as a generic STRUCT without a logical type/row schema, and the conversion cannot proceed.","triggerScenarios":"A Beam schema field typed as STRUCT whose FieldType was created without attaching a RowSchema, encountered during beamRowFromKafkaStruct conversion.","commonSituations":"A bug in upstream schema inference (beamField producing STRUCT without row schema), or custom schema registration where nested rows weren't fully specified.","solutions":["Ensure nested Beam fields are built with Schema.FieldType.row(...) carrying the nested Schema.","Upgrade Beam if the schema inference for nested Debezium structs is at fault.","Inspect the Beam schema produced by KafkaConnectUtils.beamSchema and fix the field definition at its source."],"exampleFix":"// before\nSchema.FieldType.structType() // no row schema attached\n// after\nSchema.FieldType.row(nestedSchema)","handlingStrategy":"validation","validationCode":"for (Field f : beamSchema.getFields()) {\n  if (f.getType().getTypeName() == Schema.TypeName.ROW\n      && f.getType().getRowSchema() == null) {\n    throw new IllegalStateException(\"Field \" + f.getName() + \" lacks row schema\");\n  }\n}","typeGuard":"boolean hasRowSchema(Schema.Field f) {\n  return f.getType().getTypeName() != Schema.TypeName.ROW\n      || f.getType().getRowSchema() != null;\n}","tryCatchPattern":null,"preventionTips":["Always build nested fields with Schema.FieldType.row(nestedSchema)","Verify beamSchema output of KafkaConnectUtils in unit tests","Pin a Beam version whose nested-struct inference is correct"],"tags":["java","schema-conversion","apache-beam"],"backgroundTag":"schema-validation-failed","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"}