{"record":{"id":"343e577fe7b67185","repo":"apache/beam","slug":"s-is-not-nullable-in-map-field-s","errorCode":null,"errorMessage":"%s is not nullable in Map field %s","messagePattern":"(.+?) is not nullable in Map field (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowUtils.java","lineNumber":520,"sourceCode":"        RowPosition rowPosition,\n        FieldType keyType,\n        FieldType valueType,\n        Map<Object, Object> valueMap,\n        RowFieldMatcher matcher) {\n      Map<Object, Object> retValue = null;\n      FieldOverride override = override(rowPosition);\n      if (override != null) {\n        valueMap = (Map<Object, Object>) override.getOverrideValue();\n      }\n\n      if (valueMap != null) {\n        RowPosition elementPosition = rowPosition.withMapQualifier();\n\n        retValue = Maps.newHashMapWithExpectedSize(valueMap.size());\n        for (Entry<Object, Object> kv : valueMap.entrySet()) {\n          if (kv.getValue() == null) {\n            if (!valueType.getNullable()) {\n              throw new IllegalArgumentException(\n                  String.format(\n                      \"%s is not nullable in Map field %s\", valueType, rowPosition.descriptor));\n            }\n            retValue.put(matcher.match(this, keyType, elementPosition, kv.getKey()), null);\n          } else {\n            retValue.put(\n                matcher.match(this, keyType, elementPosition, kv.getKey()),\n                matcher.match(this, valueType, elementPosition, kv.getValue()));\n          }\n        }\n      }\n      return retValue;\n    }\n\n    @Override\n    public Object processLogicalType(\n        RowPosition rowPosition, LogicalType logicalType, Object value, RowFieldMatcher matcher) {\n      Object retValue = null;","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowUtils.java#L502-L538","documentation":"For MAP fields, Beam enforces nullability of map values (keys must be non-null/non-nullable by schema rules). When processMap captures a map entry whose value is null and the value FieldType is declared non-nullable, it throws IllegalArgumentException.","triggerScenarios":"RowUtils.processMap iterating a Map field during schema attach/match; any entry with kv.getValue() == null while valueType.getNullable() is false.","commonSituations":"Maps assembled from sparse data where lookups returned null; schema evolved to non-nullable values; deserializing older records containing null map values.","solutions":["Declare map values nullable: Schema.FieldType.map(keyType, valueType.withNullable(true))","Remove or default null values before Row creation (Maps.filterValues(m, Objects::nonNull) or fill defaults)","Fix upstream producers so map values are never null"],"exampleFix":"// before\nMap<String, Integer> counts = ...; // may contain null values\n// after\ncounts.values().removeIf(Objects::isNull);","handlingStrategy":"validation","validationCode":"map.values().removeIf(Objects::isNull); // or use valueType.withNullable(true)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never put null values in maps destined for Rows with non-nullable value types","Use Maps.filterValues to sanitize input","Declare map value nullability explicitly to match data"],"tags":["java","apache-beam","schema","nullability","map"],"backgroundTag":"null-value-in-non-nullable-field","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"}