{"record":{"id":"991b80ab103845df","repo":"apache/druid","slug":"unable-to-parse-row-s-991b80","errorCode":null,"errorMessage":"Unable to parse row [%s]","messagePattern":"Unable to parse row \\[(.+?)\\]","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/parsers/JSONPathParser.java","lineNumber":77,"sourceCode":"  {\n  }\n\n  /**\n   * @param input JSON string. The root must be a JSON object, not an array.\n   *              e.g., {\"valid\": \"true\"} and {\"valid\":[1,2,3]} are supported\n   *              but [{\"invalid\": \"true\"}] and [1,2,3] are not.\n   *\n   * @return A map of field names and values\n   */\n  @Override\n  public Map<String, Object> parseToMap(String input)\n  {\n    try {\n      JsonNode document = mapper.readValue(input, JsonNode.class);\n      return flattener.flatten(document);\n    }\n    catch (Exception e) {\n      throw new ParseException(input, e, \"Unable to parse row [%s]\", input);\n    }\n  }\n}\n","sourceCodeStart":59,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/parsers/JSONPathParser.java#L59-L81","documentation":"JSONPathParser.parseToMap parses an input string as JSON with Jackson and flattens the resulting JsonNode into a Map using a JSONPath/JSON-flattener spec. If Jackson cannot parse the input as JSON, or the flattening step fails, the parser wraps the cause in a ParseException reporting the offending raw row.","triggerScenarios":"Calling parseToMap(String) (or the generic Parser interface used by ingestion) with input that is not valid JSON (truncated line, concatenated JSON objects, CSV/plain text), or JSON whose structure defeats the configured flattener (e.g. usingField/path mismatches causing flatten exceptions).","commonSituations":"Kafka/Kinesis records that are not pure JSON (e.g. Avro-encoded or newline-delimited batches fed as single rows); empty strings from skipped queue messages; encoding issues corrupting payloads; wrong parser chosen for the data format.","solutions":["Validate and fix the input data: ensure each record is a single, well-formed JSON object.","Verify the ingestion spec uses the correct parser (e.g. 'string' JSON parser, not JSONPath) for the actual data format.","Check for encoding/truncation issues at the source (char-set mismatch, partial reads).","If flatten spec fields don't match the document shape, correct the flattenSpec (useFieldDiscovery, paths).","Catch ParseException in the ingestion path and route bad rows to a dead-letter/sink instead of failing the task."],"exampleFix":"// before\nMap<String, Object> row = new JSONPathParser(flattenSpec).parseToMap(rawLine); // rawLine may be \"{a:1}{b:2}\"\n// after\nObjectMapper mapper = new ObjectMapper();\nif (rawLine == null || rawLine.trim().isEmpty()) { continue; }\ntry {\n  mapper.readTree(rawLine); // pre-validate\n} catch (IOException e) { sendToDeadLetter(rawLine); continue; }\nMap<String, Object> row = parser.parseToMap(rawLine);","handlingStrategy":"try-catch","validationCode":"private static boolean isValidJson(final ObjectMapper mapper, final String input) {\n  if (input == null || input.trim().isEmpty()) { return false; }\n  try { mapper.readTree(input); return true; } catch (IOException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  Map<String, Object> row = parser.parseToMap(input);\n} catch (ParseException e) {\n  log.warn(e, \"Skipping unparseable row: %s\", input);\n  // forward to dead-letter topic / reject report\n}","preventionTips":["Pre-validate payloads are single well-formed JSON objects at the producer.","Match parser type to data format (don't use JSONPathParser for non-JSON).","Keep flattenSpec paths consistent with the actual document shape.","Monitor ingestion reject counts to catch producer regressions early."],"tags":["json","parsing","ingestion","parseexception"],"backgroundTag":"json-parse-error","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}