fluent/fluentd · error · Fluent::ConfigError

@type is required in <parse>

Error message

@type is required in <parse>

What it means

Fluent::ConfigError from parser_create. A parser plugin (json, regexp, apache2, nginx, syslog, csv, tsv, none, ...) is chosen by @type; when the helper receives a conf object (Element or Hash) without '@type' and no type: or default_type: argument was given, it has no parser class to instantiate and raises.

Source

Thrown at lib/fluent/plugin_helper/parser.rb:32

#    limitations under the License.
#

require 'fluent/plugin'
require 'fluent/plugin/parser'
require 'fluent/config/element'
require 'fluent/configurable'

module Fluent
  module PluginHelper
    module Parser
      def parser_create(usage: '', type: nil, conf: nil, default_type: nil)
        parser = @_parsers[usage]
        return parser if parser && !type && !conf

        type = if type
                 type
               elsif conf && conf.respond_to?(:[])
                 raise Fluent::ConfigError, "@type is required in <parse>" unless conf['@type']
                 conf['@type']
               elsif default_type
                 default_type
               else
                 raise ArgumentError, "BUG: both type and conf are not specified"
               end
        parser = Fluent::Plugin.new_parser(type, parent: self)
        config = case conf
                 when Fluent::Config::Element
                   conf
                 when Hash
                   # in code, programmer may use symbols as keys, but Element needs strings
                   conf = Hash[conf.map{|k,v| [k.to_s, v]}]
                   Fluent::Config::Element.new('parse', usage, conf, [])
                 when nil
                   Fluent::Config::Element.new('parse', usage, {}, [])
                 else
                   raise ArgumentError, "BUG: conf must be a Element, Hash (or unspecified), but '#{conf.class}'"

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Add an @type line inside the <parse> section, e.g. @type json or @type regexp
  2. In plugin code, pass type: explicitly or provide default_type: to parser_create
  3. Check <parse> indentation so it belongs to the plugin section that reads it

Example fix

# before
<source>
  @type tail
  <parse>
    time_format %Y-%m-%dT%H:%M:%S
  </parse>
</source>

# after
<source>
  @type tail
  <parse>
    @type json
    time_format %Y-%m-%dT%H:%M:%S
  </parse>
</source>
Defensive patterns

Strategy: validation

Validate before calling

# guard before parser_create
type = type || conf['@type'] if conf.respond_to?(:[])
raise Fluent::ConfigError, '<parse> needs @type' unless type || default_type
parser = parser_create(usage: 'p', type: type, conf: conf, default_type: default_type)

Try / catch

begin
  parser_create(usage: usage, conf: conf, default_type: 'none')
rescue Fluent::ConfigError => e
  raise Fluent::ConfigError, "in <parse #{usage}>: #{e.message}"
end

Prevention

When it happens

Trigger: parser_create(usage: 'p', conf: conf) where conf lacks '@type', with neither type: nor default_type:. User-facing equivalent: a <parse> section in fluent.conf missing its @type line.

Common situations: <parse> block missing '@type json'/'@type regexp'; writing 'type' instead of '@type'; <parse> nested under the wrong parent so @type is treated as a plain option; plugin code passing a Hash without the '@type' key.

Related errors


AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21). Data as JSON: /api/errors/37d7e32a7203d065. Report an issue: GitHub.