apache/beam · error · IllegalArgumentException

Unable to parse json object

Error message

Unable to parse json object: {jsonString}

What it means

jsonToRow wraps remaining IOExceptions (not Json parse/mapping ones) into IllegalArgumentException('Unable to parse json object: <string>'). These are lower-level I/O problems while reading/parsing the JSON string that Jackson did not classify as JSON syntax/mapping errors.

Solutions

  1. Read the wrapped cause for the root IO problem
  2. Ensure the input is a well-formed String and the ObjectMapper is a plain Jackson instance (or RowJson-default)
  3. Validate the JSON string separately before calling jsonToRow
  4. Catch IllegalArgumentException distinctly from UnsupportedRowJsonException

Example fix

try {
  Row row = RowJsonUtils.jsonToRow(mapper, json);
} catch (IllegalArgumentException e) {
  LOG.error("Bad json input: {}", e.getMessage(), e.getCause());
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (jsonString == null || jsonString.isEmpty()) throw new IllegalArgumentException("Empty json input");

Try / catch

try { Row r = RowJsonUtils.jsonToRow(mapper, json); } catch (IllegalArgumentException e) { /* IO-level problem: log e.getCause() and raw input */ }

Prevention

When it happens

Trigger: jsonToRow where objectMapper.readValue throws a plain IOException - rare with String input, e.g. low-level decoding issues or an unexpected IOException from a custom ObjectMapper/input source.

Common situations: Custom ObjectMappers with unusual input handling; charset/encoding problems; misdiagnosed IO failures from wrapped readers.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1e26dfcc19ad2191. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJsonUtils.java:140

  }

  public static ObjectMapper newObjectMapperWith(RowJson.RowJsonSerializer serializer) {
    SimpleModule module = new SimpleModule("rowSerializationModule");
    module.addSerializer(Row.class, serializer);

    ObjectMapper objectMapper = new ObjectMapper(createJsonFactory(MAX_STRING_LENGTH));
    objectMapper.registerModule(module);

    return objectMapper;
  }

  public static Row jsonToRow(ObjectMapper objectMapper, String jsonString) {
    try {
      return objectMapper.readValue(jsonString, Row.class);
    } catch (JsonParseException | JsonMappingException jsonException) {
      throw new UnsupportedRowJsonException("Unable to parse Row", jsonException);
    } catch (IOException e) {
      throw new IllegalArgumentException("Unable to parse json object: " + jsonString, e);
    }
  }

  public static String rowToJson(ObjectMapper objectMapper, Row row) {
    try {
      return objectMapper.writeValueAsString(row);
    } catch (JsonProcessingException e) {
      throw new IllegalArgumentException("Unable to serialize row: " + row, e);
    }
  }
}

View on GitHub (pinned to 12126d8942)