{"record":{"id":"94392c101754a3fc","repo":"apache/beam","slug":"unable-to-serialize-row-row","errorCode":null,"errorMessage":"Unable to serialize row: {row}","messagePattern":"Unable to serialize row: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJsonUtils.java","lineNumber":148,"sourceCode":"\n    return objectMapper;\n  }\n\n  public static Row jsonToRow(ObjectMapper objectMapper, String jsonString) {\n    try {\n      return objectMapper.readValue(jsonString, Row.class);\n    } catch (JsonParseException | JsonMappingException jsonException) {\n      throw new UnsupportedRowJsonException(\"Unable to parse Row\", jsonException);\n    } catch (IOException e) {\n      throw new IllegalArgumentException(\"Unable to parse json object: \" + jsonString, e);\n    }\n  }\n\n  public static String rowToJson(ObjectMapper objectMapper, Row row) {\n    try {\n      return objectMapper.writeValueAsString(row);\n    } catch (JsonProcessingException e) {\n      throw new IllegalArgumentException(\"Unable to serialize row: \" + row, e);\n    }\n  }\n}\n","sourceCodeStart":130,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJsonUtils.java#L130-L152","documentation":"RowJsonUtils.rowToJson serializes a Beam Row to a JSON string and wraps JsonProcessingException into IllegalArgumentException('Unable to serialize row: <row>'). Serialization failures are typically Row values that the RowJson serializer cannot represent (see writeValue's unsupported types) or Jackson generation failures.","triggerScenarios":"rowToJson(objectMapper, row) where the Row contains fields the serializer cannot write (unsupported schema types, illegal values) or a Jackson generation problem occurs mid-write.","commonSituations":"Rows containing logical/custom types unsupported by the writer; NaN/infinite doubles; schema evolution producing types the serializer switch doesn't cover.","solutions":["Check getCause() (JsonProcessingException) for the exact field/value that failed","Convert unsupported field types to supported ones (base types, String) before serializing","Use a RowJson ObjectMapper configured for Row serialization","Catch IllegalArgumentException around rowToJson and skip/re-encode offending rows"],"exampleFix":"try {\n  String json = RowJsonUtils.rowToJson(mapper, row);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Cannot serialize row: {}\", e.getMessage(), e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// pre-check: ensure all field values map to supported writer types\nrow.getSchema().getFields().forEach(f -> {\n  if (!SUPPORTED_WRITER_TYPES.contains(f.getType().getTypeName())) throw new IllegalStateException(\"Unsupported: \" + f.getName());\n});","typeGuard":null,"tryCatchPattern":"try { String s = RowJsonUtils.rowToJson(mapper, row); } catch (IllegalArgumentException e) { /* e.getCause() is JsonProcessingException naming the failing field */ }","preventionTips":["Avoid NaN/Infinite values in Row fields","Convert unsupported logical types before serializing","Test serialization whenever the schema changes"],"tags":["beam","json","serialization"],"backgroundTag":"json-serialization-failed","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"}