{"record":{"id":"2143a0ade618e79c","repo":"apache/beam","slug":"unexpected-null-for-value-type-fielddescriptor-getname","errorCode":null,"errorMessage":"Unexpected null for value type: \" + fieldDescriptor.getName()","messagePattern":"Unexpected null for value type: \" \\+ fieldDescriptor\\.getName\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java","lineNumber":353,"sourceCode":"      case ITERABLE:\n        Iterable<Object> iterable = (Iterable<Object>) value;\n        @Nullable FieldType iterableElementType = beamFieldType.getCollectionElementType();\n        if (iterableElementType == null) {\n          throw new RuntimeException(\"Unexpected null element type: \" + fieldDescriptor.getName());\n        }\n\n        return StreamSupport.stream(iterable.spliterator(), false)\n            .map(v -> toProtoValue(fieldDescriptor, iterableElementType, v))\n            .collect(Collectors.toList());\n      case MAP:\n        Map<Object, Object> map = (Map<Object, Object>) value;\n        @Nullable FieldType keyType = beamFieldType.getMapKeyType();\n        @Nullable FieldType valueType = beamFieldType.getMapValueType();\n        if (keyType == null) {\n          throw new RuntimeException(\"Unexpected null for key type: \" + fieldDescriptor.getName());\n        }\n        if (valueType == null) {\n          throw new RuntimeException(\n              \"Unexpected null for value type: \" + fieldDescriptor.getName());\n        }\n\n        return map.entrySet().stream()\n            .map(\n                (Map.Entry<Object, Object> entry) ->\n                    mapEntryToProtoValue(\n                        fieldDescriptor.getMessageType(), keyType, valueType, entry))\n            .collect(Collectors.toList());\n      default:\n        return scalarToProtoValue(fieldDescriptor, beamFieldType, value);\n    }\n  }\n\n  private static DynamicMessage buildTimestampPicosMessage(\n      Descriptor timestampPicosDescriptor, Instant instant) {\n    long seconds = instant.getEpochSecond();\n    long picoseconds = instant.getNano() * 1000L; // nanos → picos","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProto.java#L335-L371","documentation":"The value-side counterpart in toProtoValue's MAP branch: getMapValueType() returned null for a MAP field, so entry values cannot be converted to the key/value STRUCT expected by BigQuery, and the converter throws naming the proto field.","triggerScenarios":"toProtoValue case MAP where beamFieldType.getMapValueType() returns null while processing row data containing an actual map value.","commonSituations":"FieldTypes constructed with only a key type; inference from raw/non-generic Maps; schemas shared between pipeline versions where one side lacks value-type metadata.","solutions":["Declare the field as FieldType.map(keyType, valueType) with a concrete value type.","Use generic Map<K,V> in schema classes so the value type is inferred.","Validate all MAP fields have both key and value types before the BigQuery sink.","Handle the RuntimeException at row-conversion time to surface which field is malformed."],"exampleFix":"// before\nFieldType m = FieldType.builder().setType(TypeName.MAP).setMapKeyType(FieldType.int64()).build();\n// after\nFieldType m = FieldType.map(FieldType.int64(), FieldType.double_());","handlingStrategy":"validation","validationCode":"for (Schema.Field f : schema.getFields()) {\n  if (f.getType().getTypeName() == Schema.TypeName.MAP && f.getType().getMapValueType() == null) {\n    throw new IllegalArgumentException(\"Field \" + f.getName() + \" missing map value type\");\n  }\n}","typeGuard":"boolean hasMapValueType(Schema.Field f) {\n  return f.getType().getTypeName() != Schema.TypeName.MAP || f.getType().getMapValueType() != null;\n}","tryCatchPattern":"try {\n  value = toProtoValue(fieldDescriptor, beamFieldType, v);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unexpected null for value type\")) {\n    throw new SchemaException(\"Map field lacks value type: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Declare full map types with FieldType.map(k, v)","Avoid raw/non-generic Map fields","Validate schemas before writing to BigQuery"],"tags":["java","apache-beam","bigquery","map-type"],"backgroundTag":"internal-invariant-violation","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"}