{"record":{"id":"37d7e32a7203d065","repo":"fluent/fluentd","slug":"type-is-required-in-parse","errorCode":null,"errorMessage":"@type is required in <parse>","messagePattern":"@type is required in <parse>","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/parser.rb","lineNumber":32,"sourceCode":"#    limitations under the License.\n#\n\nrequire 'fluent/plugin'\nrequire 'fluent/plugin/parser'\nrequire 'fluent/config/element'\nrequire 'fluent/configurable'\n\nmodule Fluent\n  module PluginHelper\n    module Parser\n      def parser_create(usage: '', type: nil, conf: nil, default_type: nil)\n        parser = @_parsers[usage]\n        return parser if parser && !type && !conf\n\n        type = if type\n                 type\n               elsif conf && conf.respond_to?(:[])\n                 raise Fluent::ConfigError, \"@type is required in <parse>\" unless conf['@type']\n                 conf['@type']\n               elsif default_type\n                 default_type\n               else\n                 raise ArgumentError, \"BUG: both type and conf are not specified\"\n               end\n        parser = Fluent::Plugin.new_parser(type, parent: self)\n        config = case conf\n                 when Fluent::Config::Element\n                   conf\n                 when Hash\n                   # in code, programmer may use symbols as keys, but Element needs strings\n                   conf = Hash[conf.map{|k,v| [k.to_s, v]}]\n                   Fluent::Config::Element.new('parse', usage, conf, [])\n                 when nil\n                   Fluent::Config::Element.new('parse', usage, {}, [])\n                 else\n                   raise ArgumentError, \"BUG: conf must be a Element, Hash (or unspecified), but '#{conf.class}'\"","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/parser.rb#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"<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.","solutions":["Add an @type line inside the <parse> section, e.g. @type json or @type regexp","In plugin code, pass type: explicitly or provide default_type: to parser_create","Check <parse> indentation so it belongs to the plugin section that reads it"],"exampleFix":"# before\n<source>\n  @type tail\n  <parse>\n    time_format %Y-%m-%dT%H:%M:%S\n  </parse>\n</source>\n\n# after\n<source>\n  @type tail\n  <parse>\n    @type json\n    time_format %Y-%m-%dT%H:%M:%S\n  </parse>\n</source>","handlingStrategy":"validation","validationCode":"# guard before parser_create\ntype = type || conf['@type'] if conf.respond_to?(:[])\nraise Fluent::ConfigError, '<parse> needs @type' unless type || default_type\nparser = parser_create(usage: 'p', type: type, conf: conf, default_type: default_type)","typeGuard":null,"tryCatchPattern":"begin\n  parser_create(usage: usage, conf: conf, default_type: 'none')\nrescue Fluent::ConfigError => e\n  raise Fluent::ConfigError, \"in <parse #{usage}>: #{e.message}\"\nend","preventionTips":["Write @type as the first line of every <parse> section","Pass default_type: when parsing user-supplied conf","Run --dry-run on config changes"],"tags":["fluentd","parser","configuration","plugin-helper"],"backgroundTag":"missing-type-annotation","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}