{"record":{"id":"84766f85d376e656","repo":"fluent/fluentd","slug":"key-name-does-not-exist","errorCode":null,"errorMessage":"#{@key_name} does not exist","messagePattern":"#(.+?) does not exist","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"warning","filePath":"lib/fluent/plugin/filter_parser.rb","lineNumber":66,"sourceCode":"    def configure(conf)\n      compat_parameters_convert(conf, :parser)\n\n      super\n\n      @accessor = record_accessor_create(@key_name)\n      @parser = parser_create\n    end\n\n    REPLACE_CHAR = '?'.freeze\n\n    def filter_stream(tag, es)\n      new_es = Fluent::MultiEventStream.new\n      es.each do |time, record|\n        begin\n          raw_value = @accessor.call(record)\n          if raw_value.nil?\n            new_es.add(time, handle_parsed(tag, record, time, {})) if @reserve_data\n            raise ArgumentError, \"#{@key_name} does not exist\"\n          else\n            filter_one_record(tag, time, record, raw_value) do |result_time, result_record|\n              new_es.add(result_time, result_record)\n            end\n          end\n        rescue => e\n          router.emit_error_event(tag, time, record, e) if @emit_invalid_record_to_error\n        end\n      end\n      new_es\n    end\n\n    private\n\n    def filter_one_record(tag, time, record, raw_value)\n      begin\n        @parser.parse(raw_value) do |t, values|\n          if values","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/filter_parser.rb#L48-L84","documentation":"The parser filter reads the field named by key_name from each record via a record accessor (nested paths like $.payload.data supported). When the accessor returns nil, filter_stream raises ArgumentError '<key_name> does not exist' for that record. The surrounding rescue routes the exception to router.emit_error_event only when emit_invalid_record_to_error is true (the default); with reserve_data true the original record (with empty parse results) is still added to the output stream before the raise, otherwise the record is silently dropped.","triggerScenarios":"Any event reaching the filter whose record lacks key_name or has it explicitly nil: heterogeneous streams, typo in key_name, wrong nesting (using payload when data lives at $.payload.data), or upstream format changes.","commonSituations":"Mixed producers where only some events carry the parsed field; key renamed upstream; JSON that sometimes wraps the payload one level deeper; key_name copied from another pipeline.","solutions":["Correct key_name to match the real field, including record accessor syntax for nested values ($.payload.data).","For streams that legitimately lack the field, keep emit_invalid_record_to_error true and route the @ERROR label to a file/sink to inspect misses.","Set reserve_data true if records without the field should still flow through (original record kept).","Pre-filter with grep to drop or tag records without the key before the parser filter."],"exampleFix":"# before\n<filter app.**>\n  @type parser\n  key_name payload\n  <parse>\n    @type json\n  </parse>\n</filter>\n# after: misses are kept and routed for inspection\n<filter app.**>\n  @type parser\n  key_name payload\n  reserve_data true\n  emit_invalid_record_to_error true\n  <parse>\n    @type json\n  </parse>\n</filter>\n<label @ERROR>\n  <match **>\n    @type file\n    path /var/log/fluent/error/parser-misses\n  </match>\n</label>","handlingStrategy":"validation","validationCode":"# verify every record has the field before enabling the parser filter\naccessor = Fluent::RecordAccessor.new('payload') # or '$.payload.data'\nmissing = events.count { |_time, record| accessor.call(record).nil? }\nabort \"#{missing} records lack key_name\" if missing > 0","typeGuard":"->(record, key) { record.is_a?(Hash) && !record[key].nil? }","tryCatchPattern":"# in a custom filter around parser logic:\nbegin\n  filter_stream(tag, es)\nrescue ArgumentError => e\n  router.emit_error_event(tag, Fluent::EventTime.now, {}, e) if e.message.end_with?('does not exist')\nend","preventionTips":["Confirm the exact field (including $.nested.paths) against sample records.","Keep emit_invalid_record_to_error true and monitor the @ERROR stream.","Use reserve_data true when field-less records must survive.","Pre-tag missing-field records with a grep filter to route them separately."],"tags":["fluentd","ruby","filter-parser","missing-field","per-record-error"],"backgroundTag":"missing-record-field","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}