fluent/fluentd · error · NotImplementedError
Implement this method in child class
Error message
Implement this method in child class
What it means
Fluent::Plugin::Parser#parse is an abstract method (lib/fluent/plugin/parser.rb:144) that only raises NotImplementedError; every concrete parser plugin (json, regexp, multiline, ...) must override it. The error means code is running the base-class implementation: either an abstract parser was instantiated or a custom parser subclass forgot to define #parse. It surfaces at the first parse call, not at configure time.
Source
Thrown at lib/fluent/plugin/parser.rb:144
else
nil
end
end
def start
super
@timeout_checker.start if @timeout_checker
end
def stop
super
@timeout_checker.stop if @timeout_checker
end
def parse(text, &block)
raise NotImplementedError, "Implement this method in child class"
end
def parse_with_timeout(text, &block)
@timeout_checker.execute {
parse_orig(text, &block)
}
rescue UncatchableError
log.warn "parsing timed out with #{self.class}: text = #{text}"
# Return nil instead of raising error. in_tail or other plugin can emit broken line.
yield nil, nil
end
def call(*a, &b)
# Keep backward compatibility for existing plugins
# TODO: warn when deprecated
parse(*a, &b)
end
View on GitHub (pinned to dd45c6e18d)
Solutions
- Implement def parse(text, &block) in your parser subclass that yields(time, record) — e.g. yield Fluent::EventTime.now, {'raw' => text}.
- Verify the method exists before use: parser.class.instance_methods(false).include?(:parse).
- Make sure the method accepts the text argument and uses yield (not return) to deliver results.
- If you meant to use a built-in parser, instantiate the concrete type (json, regexp, none, ...) via Fluent::Plugin.new_parser.
Example fix
# before
class MyParser < Fluent::Plugin::Parser
Fluent::Plugin.register_parser('mytype', self)
# no #parse -> NotImplementedError on first call
end
# after
class MyParser < Fluent::Plugin::Parser
Fluent::Plugin.register_parser('mytype', self)
def parse(text)
yield Fluent::EventTime.now, {'raw' => text}
end
end Defensive patterns
Strategy: validation
Validate before calling
# fail fast at plugin load time instead of first parse
def assert_parser_implements_parse!(parser)
klass = parser.is_a?(Class) ? parser : parser.class
unless klass.instance_methods(false).include?(:parse)
raise "parser #{klass} does not implement #parse"
end
end Try / catch
begin
parser.call(text) { |t, r| handle(t, r) }
rescue NotImplementedError
log.error "parser #{parser.class} is abstract; check @type"
# fall back to a concrete parser, e.g. Fluent::Plugin.new_parser('none')
end Prevention
- Smoke-test every custom parser with one call in its spec suite.
- Instantiate parsers only via Fluent::Plugin.new_parser with a registered concrete type.
- Name the method exactly 'parse' accepting text and yielding time/record.
When it happens
Trigger: Creating a parser with Fluent::Plugin.new_parser('mytype') where the registered plugin class does not define parse(text, &block); calling parser.call(text) (which delegates to parse for backward compatibility) on such a plugin; subclassing Fluent::Plugin::Parser in a gem but naming the method parse_line or giving it the wrong arity so the base method stays in the lookup path.
Common situations: Developing a custom parser plugin and misspelling/omitting #parse; registering the base class or a stub class by accident; in_tail/in_http configured with @type pointing to an incompletely implemented parser gem; version upgrades renaming expected method signatures.
Related errors
- Optional API #parse_io is not implemented
- Optional API #parse_partial_data is not implemented
- Implement this method in child class
- Unknown feature for parser plugin: #{feature}
- unknown value conversion for key:'#{field_name}', type:'#{ty
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/6d3cd8148446d49f.
Report an issue: GitHub.