{"record":{"id":"0fdc4e0b5d512056","repo":"fluent/fluentd","slug":"invalid-regexp-in-key-e","errorCode":null,"errorMessage":"Invalid regexp in #{key}: #{e}","messagePattern":"Invalid regexp in #(.+?): #(.+?)","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/parser_multiline.rb","lineNumber":144,"sourceCode":"        }\n      end\n\n      def check_format_range(conf)\n        invalid_formats = conf.keys.select { |k|\n          m = k.match(/^format(\\d+)$/)\n          m ? !((1..FORMAT_MAX_NUM).include?(m[1].to_i)) : false\n        }\n        unless invalid_formats.empty?\n          raise Fluent::ConfigError, \"Invalid formatN found. N should be 1 - #{FORMAT_MAX_NUM}: \" + invalid_formats.join(\",\")\n        end\n      end\n\n      def check_format_regexp(format, key)\n        if format[0] == '/' && format[-1] == '/'\n          begin\n            Regexp.new(format[1..-2], Regexp::MULTILINE)\n          rescue => e\n            raise Fluent::ConfigError, \"Invalid regexp in #{key}: #{e}\"\n          end\n        else\n          raise Fluent::ConfigError, \"format should be Regexp, need //, in #{key}: '#{format}'\"\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":126,"sourceCodeEnd":153,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/parser_multiline.rb#L126-L153","documentation":"MultilineParser#check_format_regexp (lib/fluent/plugin/parser_multiline.rb:144) compiles an individual formatN or format_firstline value (delimiters '/' stripped) with Regexp::MULTILINE and wraps any RegexpError in Fluent::ConfigError. Unlike error 230 (which validates the joined regex), this validates each piece separately, pinpointing the exact key whose regex body is invalid Ruby regexp syntax.","triggerScenarios":"format3 /(?<a>\\d+/ (unbalanced group); format_firstline /\\d{4\\/\\d{2}/ with an unescaped '/' inside; quantifier mistakes like /a{,3}/ or /a**/; lookbehind constructs unsupported by fluentd's Ruby version.","commonSituations":"Hand-editing multiline formats for application logs; escaping regressions when configs pass through templating (Helm, ERB) that eats backslashes; regexes copied from PCRE-style tools (grep, Logstash) using syntax Ruby rejects.","solutions":["Reproduce the compile error standalone: ruby -e \"Regexp.new(File.read? 'body', Regexp::MULTILINE)\" or paste the body into a Ruby shell.","Escape embedded '/' inside the body as '\\\\/' or restructure the pattern.","Validate configs in CI with fluentd --dry-run.","Prefer simple anchor-heavy patterns and test them against sample log lines with ruby's Regexp before deploying."],"exampleFix":"# before\nformat_firstline /^2021\\/\\d{2/  # unbalanced brace -> RegexpError\n# after\nformat_firstline /^2021\\/\\d{2}\\//","handlingStrategy":"validation","validationCode":"# compile each formatN body before deploy\nformats = ['/^\\\\d{4}-/', '(?<t>\\\\d{2}:\\\\d{2})']\nformats.each { |body| Regexp.new(body, Regexp::MULTILINE) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compile-test regexes in a Ruby shell (fluentd uses Ruby regexp, not PCRE).","Escape embedded '/' inside slash-delimited format bodies.","Beware templating layers (Helm/ERB) mangling backslashes; compare rendered output."],"tags":["fluentd","multiline-parser","config-error","regex"],"backgroundTag":"invalid-regex-in-config","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}