{"record":{"id":"904e8c41648d00e4","repo":"fluent/fluentd","slug":"invalid-formatn-found-n-should-be-1-format-ma","errorCode":null,"errorMessage":"Invalid formatN found. N should be 1 - #{FORMAT_MAX_NUM}: #{invalid_formats.join(\",\")}","messagePattern":"Invalid formatN found\\. N should be 1 - #(.+?): #(.+?)","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/parser_multiline.rb","lineNumber":135,"sourceCode":"          format = conf[\"format#{i}\"]\n          if (i > 1) && prev_format.nil? && !format.nil?\n            raise Fluent::ConfigError, \"Jump of format index found. format#{i - 1} is missing.\"\n          end\n          prev_format = format\n          next if format.nil?\n\n          check_format_regexp(format, \"format#{i}\")\n          format\n        }\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":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/parser_multiline.rb#L117-L153","documentation":"MultilineParser#check_format_range (lib/fluent/plugin/parser_multiline.rb:135) scans every config key matching /\\Aformat(\\d+)\\z/ and raises Fluent::ConfigError listing any formatN whose N falls outside 1..FORMAT_MAX_NUM (20, parser_multiline.rb:30). The parser only iterates a fixed 1..20 range, so format0, format21, or format999 would otherwise be silently ignored — this error makes the omission loud. Raised at configure time.","triggerScenarios":"format21 configured for a very long multi-regex chain; format0 used as a 'prefix' section; typos like format101; configs generated programmatically that assume unbounded N.","commonSituations":"Extremely detailed multiline formats (nested stack traces) exceeding 20 segments; users assuming 0-based numbering; pasted configs from sources that numbered from a different base.","solutions":["Keep N within 1..20 and merge overflow segments into format20's pattern.","If you need more granularity, switch to a single combined regex with multiple named captures instead of many formatN keys.","Fix 0-based numbering: rename format0 to format1 and shift the rest."],"exampleFix":"# before\nformat20 /tail/\nformat21 /more-tail/   # out of range -> ConfigError\n# after\nformat20 /tail|more-tail/","handlingStrategy":"validation","validationCode":"conf.keys.each do |k|\n  if (m = k.match(/\\Aformat(\\d+)\\z/))\n    n = m[1].to_i\n    abort \"#{k} out of range\" unless (1..20).cover?(n)\n  end\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap formatN at N=20 and merge extra segments into format20.","Number from 1, never 0.","Dry-run configs to catch range violations before restart."],"tags":["fluentd","multiline-parser","config-error","format-range"],"backgroundTag":"config-parameter-validation","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}