{"record":{"id":"dcd7ab0a04d13603","repo":"apache/beam","slug":"field-name-has-a-null-value-in-the-json-object","errorCode":null,"errorMessage":"Field '{name}' has a null value in the JSON object.","messagePattern":"Field '(.+?)' has a null value in the JSON object\\.","errorType":"validation","errorClass":"UnsupportedRowJsonException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java","lineNumber":296,"sourceCode":"      if (fieldValue.type().getNullable()) {\n        if (!fieldValue.isJsonValuePresent()) {\n          switch (this.nullBehavior) {\n            case ACCEPT_MISSING_OR_NULL:\n            case REQUIRE_MISSING:\n              return null;\n            case REQUIRE_NULL:\n              throw new UnsupportedRowJsonException(\n                  \"Field '\" + fieldValue.name() + \"' is not present in the JSON object.\");\n          }\n        }\n\n        if (fieldValue.isJsonNull()) {\n          switch (this.nullBehavior) {\n            case ACCEPT_MISSING_OR_NULL:\n            case REQUIRE_NULL:\n              return null;\n            case REQUIRE_MISSING:\n              throw new UnsupportedRowJsonException(\n                  \"Field '\" + fieldValue.name() + \"' has a null value in the JSON object.\");\n          }\n        }\n      } else {\n        // field is not nullable\n        if (!fieldValue.isJsonValuePresent()) {\n          throw new UnsupportedRowJsonException(\n              \"Non-nullable field '\" + fieldValue.name() + \"' is not present in the JSON object.\");\n        } else if (fieldValue.isJsonNull()) {\n          throw new UnsupportedRowJsonException(\n              \"Non-nullable field '\" + fieldValue.name() + \"' has value null in the JSON object.\");\n        }\n      }\n\n      if (fieldValue.isRowType()) {\n        return jsonObjectToRow(fieldValue);\n      }\n","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java#L278-L314","documentation":"RowJson's extractor throws UnsupportedRowJsonException when nullBehavior is REQUIRE_MISSING but the field is present with an explicit JSON null value. This enforces the opposite strictness of error 708: nulls must be represented by absence, not by JSON null. Raised in extractJsonNodeValue during deserialization.","triggerScenarios":"Deserializing JSON containing {\"field\": null} while RowJson is configured with nullBehavior=REQUIRE_MISSING for that field.","commonSituations":"Producers that serialize Java nulls as JSON null instead of omitting keys; mismatch between the chosen strict null policy and the producer's convention; hand-written test fixtures using null.","solutions":["Use ACCEPT_MISSING_OR_NULL nullBehavior to accept both absent keys and JSON nulls.","Change the producer to omit the key instead of writing null.","Pre-process JSON to drop null-valued keys before deserialization."],"exampleFix":"// before\n{\"user\": null}  // with nullBehavior(REQUIRE_MISSING) -> throws\n// after\n{}  // omit the key, or switch to ACCEPT_MISSING_OR_NULL","handlingStrategy":"try-catch","validationCode":"Iterator<Map.Entry<String, JsonNode>> it = json.fields();\nwhile (it.hasNext()) {\n  if (it.next().getValue().isNull()) it.remove(); // drop explicit nulls before convert\n}","typeGuard":null,"tryCatchPattern":"try {\n  Row row = jsonToRow.convert(json);\n} catch (UnsupportedRowJsonException e) {\n  LOG.warn(\"Unexpected JSON null: {}\", e.getMessage());\n  row = convertWithLenientNullBehavior(json); // ACCEPT_MISSING_OR_NULL\n}","preventionTips":["Don't use REQUIRE_MISSING with producers that serialize nulls as JSON null.","Strip null-valued keys before deserialization or use ACCEPT_MISSING_OR_NULL.","Align null conventions (absence vs explicit null) between producer and consumer.","Cover null-field fixtures in deserialization tests."],"tags":["java","apache-beam","json","deserialization","null-handling"],"backgroundTag":"null-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"}