{"record":{"id":"6998d0ab787309c9","repo":"apache/beam","slug":"map-value-type-cannot-be-null","errorCode":null,"errorMessage":"Map value type cannot be null.","messagePattern":"Map value type 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":195,"sourceCode":"        ArrayValue.Builder arrayBuilder = ArrayValue.newBuilder();\n        FieldType elementType = fieldType.getCollectionElementType();\n        if (elementType == null) {\n          throw new IllegalArgumentException(\"Collection element type cannot be null.\");\n        }\n        for (Object item : (Iterable<?>) value) {\n          arrayBuilder.addValues(\n              item == null\n                  ? Value.newBuilder()\n                      .setNullValue(com.google.protobuf.NullValue.NULL_VALUE)\n                      .build()\n                  : javaToValue(item, elementType));\n        }\n        return Value.newBuilder().setArrayValue(arrayBuilder.build()).build();\n      case MAP:\n        MapValue.Builder mapBuilder = MapValue.newBuilder();\n        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)) {","sourceCodeStart":177,"sourceCodeEnd":213,"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#L177-L213","documentation":"javaToValue converts Java Map values to Firestore MapValue protos using the FieldType's map value type. If fieldType.getMapValueType() returns null — meaning the schema field was declared as a map without specifying the value type — the converter cannot serialize entries and throws IllegalArgumentException.","triggerScenarios":"Writing Rows with MAP-typed fields whose FieldType lacks map value metadata, e.g. FieldType.of(TypeName.MAP) or a hand-built FieldType without the value-type parameter.","commonSituations":"Dynamically generated schemas missing map value types; schemas round-tripped through serialization losing nested type info; using addMapField incorrectly or constructing map field types without FieldType.map(keyType, valueType).","solutions":["Declare map fields with FieldType.map(FieldType keyType, FieldType valueType)","Validate getMapValueType() != null for all map fields before writing to Firestore","Build maps with Schema.builder().addMapField(name, keyType, valueType)"],"exampleFix":"// before\nFieldType bad = FieldType.of(TypeName.MAP); // no value type\n// after\nFieldType good = FieldType.map(FieldType.STRING, FieldType.INT64);","handlingStrategy":"validation","validationCode":"FieldType ft = schema.getField(name).getType();\nif (ft.getTypeName() == TypeName.MAP && ft.getMapValueType() == null) {\n  throw new IllegalStateException(\"Map field '\" + name + \"' lacks value type\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use FieldType.map(keyType, valueType) exclusively","Never build map FieldTypes from raw TypeName constants","Validate schemas before pipeline submission"],"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"}