{"record":{"id":"b139f438bcaecaeb","repo":"apache/druid","slug":"unable-to-parse-line","errorCode":null,"errorMessage":"Unable to parse line.","messagePattern":"Unable to parse line\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxLineProtocolReader.java","lineNumber":102,"sourceCode":"    return false;\n  }\n\n  @Override\n  public void processHeaderLine(String line)\n  {\n    // no header lines in influx line protocol\n  }\n\n  private Map<String, Object> parseLineToMap(String input)\n  {\n    CharStream charStream = new ANTLRInputStream(input);\n    InfluxLineProtocolLexer lexer = new InfluxLineProtocolLexer(charStream);\n    TokenStream tokenStream = new CommonTokenStream(lexer);\n    InfluxLineProtocolParser parser = new InfluxLineProtocolParser(tokenStream);\n\n    List<InfluxLineProtocolParser.LineContext> lines = parser.lines().line();\n    if (parser.getNumberOfSyntaxErrors() != 0) {\n      throw new ParseException(input, \"Unable to parse line.\");\n    }\n    if (lines.size() != 1) {\n      throw new ParseException(input, \"Multiple lines present; unable to parse more than one per record.\");\n    }\n\n    Map<String, Object> out = new LinkedHashMap<>();\n\n    InfluxLineProtocolParser.LineContext line = lines.get(0);\n    String measurement = parseIdentifier(line.identifier());\n\n    if (!checkWhitelist(measurement)) {\n      throw new ParseException(input, \"Metric [%s] not whitelisted.\", measurement);\n    }\n\n    out.put(MEASUREMENT_KEY, measurement);\n    if (line.tag_set() != null) {\n      line.tag_set().tag_pair().forEach(t -> parseTag(t, out));\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxLineProtocolReader.java#L84-L120","documentation":"parseLineToMap feeds the input record to an ANTLR-generated parser for the Influx line protocol. If the parser reports any syntax errors (parser.getNumberOfSyntaxErrors() != 0), the reader throws ParseException(\"Unable to parse line.\") for the full input. The record is not valid Influx line protocol per the extension's grammar.","triggerScenarios":"Streaming a record into the Influx inputSource whose text violates line-protocol grammar — missing measurement, malformed tag/field pairs, unescaped spaces or commas, missing field section, bad timestamp — so ANTLR reports syntax errors.","commonSituations":"Exported Influx data containing multiple or escaped constructs the grammar doesn't accept; CSV/other data misrouted into the influx parser; truncated records from a producer; unescaped '=' or ',' in tag keys/values; newline or quoting issues in the source file.","solutions":["Validate the offending line against Influx line-protocol syntax: measurement[,tag=k v1,...] [timestamp], and fix quoting/escaping (\\ , \\=, \\ ).","Ensure each record is exactly one line-protocol point with at least one field (fields section is mandatory).","Route non-line-protocol data to the appropriate input format instead of the influx reader.","Enable/review the reader's parse-failure logging to see the full rejected input, then correct the producer or add a pre-filter."],"exampleFix":"// before (invalid: field value unquoted string)\ncpu,host=a usage=\"high\"\n// after\ncpu,host=a usage=1.0 1710000000000000000","handlingStrategy":"validation","validationCode":"// Cheap pre-parse sanity check before ingesting\nif (line == null || line.trim().isEmpty()) throw new IllegalArgumentException(\"empty line\");\nint spaceIdx = line.indexOf(' ');\nif (spaceIdx <= 0 || spaceIdx == line.length() - 1) throw new IllegalArgumentException(\"missing fields section: \" + line);","typeGuard":null,"tryCatchPattern":"try {\n  reader.read(record);\n} catch (org.apache.druid.java.util.common.parsers.ParseException e) {\n  log.warn(\"Bad line-protocol record, skipping: {}\", e.getMessage());\n  metrics.incrementParseErrors();\n  return null; // or dead-letter the record\n}","preventionTips":["Validate sample data against Influx line-protocol rules before wiring ingestion.","Escape special characters (space, comma, equals) in measurements, tags, and string field values.","Ensure every point has a fields section; strings must be quoted.","Fix record splitting upstream so producers don't emit truncated points."],"tags":["influx","parsing","antlr","input-format"],"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"}