{"record":{"id":"d1a562ea8c917d87","repo":"fluent/fluentd","slug":"duplicated-formatter-configured-section-usage","errorCode":null,"errorMessage":"duplicated formatter configured: #{section.usage}","messagePattern":"duplicated formatter configured: #(.+?)","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/formatter.rb","lineNumber":87,"sourceCode":"\n      def self.included(mod)\n        mod.include FormatterParams\n      end\n\n      attr_reader :_formatters # for tests\n\n      def initialize\n        super\n        @_formatters_started = false\n        @_formatters = {} # usage => formatter\n      end\n\n      def configure(conf)\n        super\n\n        @formatter_configs.each do |section|\n          if @_formatters[section.usage]\n            raise Fluent::ConfigError, \"duplicated formatter configured: #{section.usage}\"\n          end\n          formatter = Plugin.new_formatter(section[:@type], parent: self)\n          formatter.configure(section.corresponding_config_element)\n          @_formatters[section.usage] = formatter\n        end\n      end\n\n      def start\n        super\n        @_formatters_started = true\n        @_formatters.each_pair do |usage, formatter|\n          formatter.start\n        end\n      end\n\n      def formatter_operate(method_name, &block)\n        @_formatters.each_pair do |usage, formatter|\n          begin","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/formatter.rb#L69-L105","documentation":"Fluent::ConfigError raised while the Formatter helper's configure processes @formatter_configs. Each <format> section is stored in @_formatters keyed by its usage label (the name in <format mylabel>, or '' when unlabelled). A second section with the same usage would silently overwrite the first formatter instance, so configure fails fast naming the duplicated usage.","triggerScenarios":"Two <format> sections in one plugin block whose labels collide: two bare <format> sections (both usage '') or two <format access_log> sections. The raise happens during plugin #configure, before start.","commonSituations":"Copy-pasting a <format> block when adding a second formatter and forgetting to give the copies distinct labels; assuming multiple unlabelled <format> sections accumulate.","solutions":["Give each <format> section a unique label such as <format json_fmt> and <format ltsv_fmt>, then select them in code with formatter_create(usage: 'json_fmt')","Delete the accidentally duplicated <format> block if only one formatter is intended"],"exampleFix":"# before\n<match app.**>\n  @type stdout\n  <format>\n    @type json\n  </format>\n  <format>\n    @type ltsv\n  </format>\n</match>\n\n# after\n<match app.**>\n  @type stdout\n  <format json_fmt>\n    @type json\n  </format>\n  <format ltsv_fmt>\n    @type ltsv\n  </format>\n</match>","handlingStrategy":"validation","validationCode":"# detect duplicate usage before configure runs\nusages = @formatter_configs.map(&:usage)\nif usages.uniq.size != usages.size\n  dup = usages.find { |u| usages.count(u) > 1 }\n  raise Fluent::ConfigError, \"duplicate <format> label: #{dup.inspect}\"\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Label every <format> section when configuring more than one","Grep configs for repeated <format ...> labels before shipping","Prefer distinct, intent-revealing labels (json_fmt, ltsv_fmt) over bare <format>"],"tags":["fluentd","formatter","configuration","duplicate"],"backgroundTag":"duplicate-config-section","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}