{"record":{"id":"ea88fb7a2265647b","repo":"apache/druid","slug":"unable-to-parse-row-s-ea88fb","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/JavaScriptParser.java","lineNumber":83,"sourceCode":"      final String function\n  )\n  {\n    this.fn = compile(function);\n  }\n\n  @Override\n  public Map<String, Object> parseToMap(String input)\n  {\n    try {\n      final Object compiled = fn.apply(input);\n      if (!(compiled instanceof Map)) {\n        throw new ParseException(input, \"JavaScript parsed value [%s] must be in {key: value} format!\", input);\n      }\n\n      return (Map) compiled;\n    }\n    catch (Exception e) {\n      throw new ParseException(input, e, \"Unable to parse row [%s]\", input);\n    }\n  }\n\n  @Override\n  public void setFieldNames(Iterable<String> fieldNames)\n  {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public List<String> getFieldNames()\n  {\n    throw new UnsupportedOperationException();\n  }\n}\n","sourceCodeStart":65,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/parsers/JavaScriptParser.java#L65-L99","documentation":"JavaScriptParser wraps any exception raised while executing the user-supplied JavaScript function into a ParseException with message \"Unable to parse row [%s]\". The parser compiles a JS script and calls it to turn each input row into a {key: value} Map; if the script throws, returns a non-Map, or compilation fails, this error is thrown for the offending row.","triggerScenarios":"Calling parseToMap(String) on a row where the configured JavaScript function throws an exception, returns null/non-Map value, or the script itself failed to compile (which surfaces as a ParseException for the first row processed).","commonSituations":"Ingestion specs using type:'javascript' parseSpec with a buggy or truncated function; script returns a JSON string or array instead of an object; JavaScript engine disabled in runtime.properties (druid.javascript.enabled=false) causing script initialization failure; JS syntax errors after copy-paste.","solutions":["Inspect the wrapped cause in the ParseException stack trace to find the actual JS error","Verify the JavaScript function returns a plain object ({key: value}), not a string, array, or null","Check that JavaScript is enabled (druid.javascript.enabled=true) in the runtime properties of the involved service","Test the function logic on a sample row locally before deploying the ingestion spec"],"exampleFix":"// before\n\"parseSpec\": {\"type\":\"javascript\", \"function\":\"function(str) { return JSON.stringify(JSON.parse(str)); }\"}\n// after\n\"parseSpec\": {\"type\":\"javascript\", \"function\":\"function(str) { return JSON.parse(str); }\"}","handlingStrategy":"try-catch","validationCode":"// validate before ingesting\nif (!script.trim().startsWith(\"function\")) throw new IllegalArgumentException(\"JS must be a function returning {key: value}\");\n// smoke-test: JSON.parse(functionResult) must yield a plain object","typeGuard":"function returnsMap(Object v) { return v instanceof java.util.Map; }","tryCatchPattern":"try { map = parser.parseToMap(row); } catch (ParseException e) { log.error(\"Row rejected: {} cause: {}\", row, e.getCause()); throw e; }","preventionTips":["Ensure the JS function returns a plain object, never a string/array/null","Test the script against sample rows before deploying","Verify druid.javascript.enabled=true in the target service"],"tags":["javascript","parser","ingestion"],"backgroundTag":"invalid-argument-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}