{"record":{"id":"553d2305104906f1","repo":"apache/beam","slug":"expected-json-array-for-field-name-instead-got-jsonnodetype","errorCode":null,"errorMessage":"Expected JSON array for field '{name}'. Instead got {jsonNodeType}","messagePattern":"Expected JSON array for field '(.+?)'\\. Instead got (.+?)","errorType":"validation","errorClass":"UnsupportedRowJsonException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java","lineNumber":366,"sourceCode":"                + \"'. Unable to convert '\"\n                + rowFieldValue.jsonValue().asText()\n                + \"' to Beam Row, it is not a JSON object. Currently only JSON objects can be parsed to Beam Rows\");\n      }\n\n      return rowFieldValue.rowSchema().getFields().stream()\n          .map(\n              schemaField ->\n                  extractJsonNodeValue(\n                      FieldValue.of(\n                          schemaField.getName(),\n                          schemaField.getType(),\n                          rowFieldValue.jsonFieldValue(schemaField.getName()))))\n          .collect(toRow(rowFieldValue.rowSchema()));\n    }\n\n    private Object jsonArrayToList(FieldValue arrayFieldValue) {\n      if (!arrayFieldValue.isJsonArray()) {\n        throw new UnsupportedRowJsonException(\n            \"Expected JSON array for field '\"\n                + arrayFieldValue.name()\n                + \"'. Instead got \"\n                + arrayFieldValue.jsonNodeType().name());\n      }\n\n      return arrayFieldValue\n          .jsonArrayElements()\n          .map(\n              jsonArrayElement ->\n                  extractJsonNodeValue(\n                      FieldValue.of(\n                          arrayFieldValue.name() + \"[]\",\n                          arrayFieldValue.arrayElementType(),\n                          jsonArrayElement)))\n          .collect(toImmutableList());\n    }\n","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java#L348-L384","documentation":"For ARRAY-typed schema fields, jsonArrayToList expects the JSON value to be an array. Any other JSON node type (object, string, number) triggers UnsupportedRowJsonException reporting the actual Jackson node type received.","triggerScenarios":"jsonToRow where an ARRAY<...> schema field receives a non-array JSON value, e.g. \"tags\": \"single\" or \"tags\": {\"a\":1}.","commonSituations":"Producer wraps a single element without making it a list; object-shaped JSON where an array was expected; schema/codegen drift between writer and reader.","solutions":["Make the JSON value a proper array, e.g. \"tags\": [\"single\"]","Adjust the schema field type to match the real JSON shape","Normalize scalar-to-array in a pre-parse transformation","Catch UnsupportedRowJsonException to flag malformed records"],"exampleFix":"// before\n{\"tags\": \"a\"}\n// after\n{\"tags\": [\"a\"]}","handlingStrategy":"validation","validationCode":"JsonNode n = json.get(\"arrayField\");\nif (n != null && !n.isArray()) throw new IllegalArgumentException(\"Array field must be a JSON array, got \" + n.getNodeType());","typeGuard":null,"tryCatchPattern":"try { Row r = RowJsonUtils.jsonToRow(mapper, json); } catch (RowJson.UnsupportedRowJsonException e) { /* handle */ }","preventionTips":["Always wrap single elements into arrays for ARRAY fields","Normalize scalar-to-list upstream","Keep schema field types aligned with producers"],"tags":["beam","json","array","deserialization"],"backgroundTag":"type-mismatch","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"}