{"record":{"id":"375e4b65d8c78e3b","repo":"fluent/fluentd","slug":"regexp-i-does-not-contain-2-parameters","errorCode":null,"errorMessage":"regexp#{i} does not contain 2 parameters","messagePattern":"regexp#(.+?) does not contain 2 parameters","errorType":"validation","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/filter_grep.rb","lineNumber":99,"sourceCode":"        desc \"The field name to which the regular expression is applied.\"\n        config_param :key, :string\n        desc \"The regular expression.\"\n        config_param :pattern, :regexp\n      end\n    end\n\n    def configure(conf)\n      super\n\n      regexp_and_conditions = {}\n      regexp_or_conditions = {}\n      exclude_and_conditions = {}\n      exclude_or_conditions = {}\n\n      (1..REGEXP_MAX_NUM).each do |i|\n        next unless conf[\"regexp#{i}\"]\n        key, regexp = conf[\"regexp#{i}\"].split(/ /, 2)\n        raise Fluent::ConfigError, \"regexp#{i} does not contain 2 parameters\" unless regexp\n        raise Fluent::ConfigError, \"regexp#{i} contains a duplicated key, #{key}\" if regexp_and_conditions[key]\n        regexp_and_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(regexp))\n      end\n\n      (1..REGEXP_MAX_NUM).each do |i|\n        next unless conf[\"exclude#{i}\"]\n        key, exclude = conf[\"exclude#{i}\"].split(/ /, 2)\n        raise Fluent::ConfigError, \"exclude#{i} does not contain 2 parameters\" unless exclude\n        raise Fluent::ConfigError, \"exclude#{i} contains a duplicated key, #{key}\" if exclude_or_conditions[key]\n        exclude_or_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(exclude))\n      end\n\n      if @regexps.size > 1\n        log.info \"Top level multiple <regexp> is interpreted as 'and' condition\"\n      end\n      @regexps.each do |e|\n        raise Fluent::ConfigError, \"Duplicate key: #{e.key}\" if regexp_and_conditions.key?(e.key)\n        regexp_and_conditions[e.key] = Expression.new(record_accessor_create(e.key), e.pattern)","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/filter_grep.rb#L81-L117","documentation":"The grep filter's deprecated numbered parameters (regexp1..regexp20) take a value of the form 'key pattern' and are parsed with String#split(/ /, 2). If the value contains no space, the regexp capture is nil and configure raises Fluent::ConfigError because the directive does not carry both required parameters.","triggerScenarios":"A config line like regexp1 message (field name only, no pattern) or regexp1 \"message\" where quoting removed the intended space; any regexpN value that splits into fewer than 2 tokens. Note regexpN itself is deprecated in favor of <regexp> sections.","commonSituations":"Migrating old v0.12 grep configs where a pattern was accidentally dropped; YAML/erb templating that renders an empty pattern variable; quoting mistakes where the pattern is in a separate quoted string that gets lost.","solutions":["Supply both tokens: regexp1 message error","Better: migrate to the modern section syntax <regexp> key message pattern /error/ ","Run fluentd --dry-run to validate before deploy","If the pattern itself contains spaces, keep it on the same line after the key (split limit 2 keeps the rest intact)"],"exampleFix":"# before\n<filter app.**>\n  @type grep\n  regexp1 message\n</filter>\n\n# after\n<filter app.**>\n  @type grep\n  <regexp>\n    key message\n    pattern /error/\n  </regexp>\n</filter>","handlingStrategy":"validation","validationCode":"# Lint deprecated grep directives before deploy\n(1..20).each do |i|\n  %W[regexp#{i} exclude#{i}].each do |k|\n    next unless (v = conf[k])\n    abort \"#{k} must be '<key> <pattern>': got '#{v}'\" unless v.include?(' ')\n  end\nend\n\n# or simply:\nsystem('fluentd --dry-run -c /etc/fluent/fluent.conf') or abort 'config invalid'","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::Plugin::GrepFilter.new.configure(conf)\nrescue Fluent::ConfigError => e\n  abort \"grep filter config rejected: #{e.message}\" # message includes the regexpN index\nend","preventionTips":["Migrate off deprecated regexpN/excludeN to <regexp>/<exclude> sections","Template configs should fail loudly when pattern variables are empty","Keep grep directive values as 'key pattern' with a single separating space","dry-run every config change in CI"],"tags":["fluentd","grep-filter","configuration","deprecated-syntax","configerror"],"backgroundTag":"config-validation-failed","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}