{"record":{"id":"562b4e28a7afea52","repo":"apache/beam","slug":"row-schema-cannot-be-null","errorCode":null,"errorMessage":"Row schema cannot be null.","messagePattern":"Row schema cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreUtils.java","lineNumber":211,"sourceCode":"        FieldType valueType = fieldType.getMapValueType();\n        if (valueType == null) {\n          throw new IllegalArgumentException(\"Map value type cannot be null.\");\n        }\n        for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {\n          Object mapValue = entry.getValue();\n          mapBuilder.putFields(\n              String.valueOf(entry.getKey()),\n              mapValue == null\n                  ? Value.newBuilder()\n                      .setNullValue(com.google.protobuf.NullValue.NULL_VALUE)\n                      .build()\n                  : javaToValue(mapValue, valueType));\n        }\n        return Value.newBuilder().setMapValue(mapBuilder.build()).build();\n      case ROW:\n        Schema rowSchema = fieldType.getRowSchema();\n        if (rowSchema == null) {\n          throw new IllegalArgumentException(\"Row schema cannot be null.\");\n        }\n        if (!(value instanceof Row)) {\n          throw new IllegalArgumentException(\"Expected Row for nested field.\");\n        }\n        MapValue.Builder nestedMapBuilder = MapValue.newBuilder();\n        Row nestedRow = (Row) value;\n        for (Field nestedField : rowSchema.getFields()) {\n          Object nestedValue = nestedRow.getValue(nestedField.getName());\n          if (nestedValue != null) {\n            nestedMapBuilder.putFields(\n                nestedField.getName(), javaToValue(nestedValue, nestedField.getType()));\n          }\n        }\n        return Value.newBuilder().setMapValue(nestedMapBuilder.build()).build();\n      default:\n        throw new IllegalArgumentException(\"Unsupported field type: \" + fieldType);\n    }\n  }","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/firestore/FirestoreUtils.java#L193-L229","documentation":"javaToValue handles ROW-typed fields by serializing a nested Beam Row into a Firestore MapValue. It requires fieldType.getRowSchema() to be non-null; a ROW FieldType without an embedded Schema carries no information about the nested fields, so the converter throws IllegalArgumentException.","triggerScenarios":"Writing Rows containing nested Row fields where the FieldType was built as FieldType.of(TypeName.ROW) without passing the nested Schema.","commonSituations":"Manually composing FieldTypes for nested records and forgetting FieldType.row(schema); schemas built via reflection where nested row schemas weren't attached; deserialized schemas missing nested metadata.","solutions":["Create nested fields with FieldType.row(Schema) providing the nested schema","Use Schema.builder().addRowField(name, nestedSchema) instead of raw TypeName construction","Check field.getType().getRowSchema() for every nested field before writing"],"exampleFix":"// before\nFieldType bad = FieldType.of(TypeName.ROW); // no nested schema\n// after\nFieldType good = FieldType.row(nestedSchema);","handlingStrategy":"validation","validationCode":"FieldType ft = schema.getField(name).getType();\nif (ft.getTypeName() == TypeName.ROW && ft.getRowSchema() == null) {\n  throw new IllegalStateException(\"ROW field '\" + name + \"' lacks nested schema\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use FieldType.row(nestedSchema) or addRowField(name, nestedSchema)","Round-trip test schema serialization to confirm nested schemas survive","Attach nested schemas at a single schema-definition site"],"tags":["java","apache-beam","firestore","schema-validation"],"backgroundTag":"missing-required-argument","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"}