{"record":{"id":"9da01fbbb98e243a","repo":"fluent/fluentd","slug":"secondary-section-cannot-have-secondary-sectio","errorCode":null,"errorMessage":"<secondary> section cannot have <secondary> section","messagePattern":"<secondary> section cannot have <secondary> section","errorType":"validation","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/output.rb","lineNumber":403,"sourceCode":"          end\n\n          if (@flush_mode != :interval) && buffer_conf.has_key?('flush_interval')\n            if buffer_conf.has_key?('flush_mode')\n              raise Fluent::ConfigError, \"'flush_interval' can't be specified when 'flush_mode' is not 'interval' explicitly: '#{@flush_mode}'\"\n            else\n              log.warn \"'flush_interval' is ignored because default 'flush_mode' is not 'interval': '#{@flush_mode}'\"\n            end\n          end\n\n          if @buffer.queued_chunks_limit_size.nil?\n            @buffer.queued_chunks_limit_size = @buffer_config.flush_thread_count\n          end\n        end\n\n        if @secondary_config\n          raise Fluent::ConfigError, \"Invalid <secondary> section for non-buffered plugin\" unless @buffering\n          raise Fluent::ConfigError, \"<secondary> section cannot have <buffer> section\" if @secondary_config.buffer\n          raise Fluent::ConfigError, \"<secondary> section cannot have <secondary> section\" if @secondary_config.secondary\n          if @buffer_config.retry_forever\n            log.warn \"<secondary> with 'retry_forever', only unrecoverable errors are moved to secondary\"\n          end\n\n          secondary_type = @secondary_config[:@type]\n          unless secondary_type\n            secondary_type = conf['@type'] # primary plugin type\n          end\n          secondary_conf = conf.elements(name: 'secondary').first\n          @secondary = Plugin.new_output(secondary_type)\n          unless @secondary.respond_to?(:acts_as_secondary)\n            raise Fluent::ConfigError, \"Failed to setup secondary plugin in '#{conf['@type']}'. '#{secondary_type}' plugin in not allowed due to non buffered output\"\n          end\n          @secondary.acts_as_secondary(self)\n          @secondary.configure(secondary_conf)\n          if (@secondary.class.to_s != \"Fluent::Plugin::SecondaryFileOutput\") &&\n             (self.class != @secondary.class) &&\n             (@custom_format || @secondary.implement?(:custom_format))","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/output.rb#L385-L421","documentation":"A `<secondary>` block was nested inside another `<secondary>` block. Fluentd supports exactly one level of secondary: when retries on the primary (including the secondary) are exhausted there is nowhere further to fall back, so a nested `@secondary_config.secondary` is rejected at output.rb:403.","triggerScenarios":"`<secondary> @type file ... <secondary> @type secondary_file ... </secondary> </secondary>` — the inner element is detected as `@secondary_config.secondary` during configure.","commonSituations":"Attempting to build a chain of fallbacks (primary → backup1 → backup2); structurally mirroring the primary `<label>`/`<match>` nesting habits inside `<secondary>`.","solutions":["Flatten to a single `<secondary>` with one plugin (typically `secondary_file`)","Put the deeper failover logic in the secondary plugin itself (e.g. secondary_file writes to local disk, and a separate input ships those files elsewhere)","Rethink the chain: make the first secondary local and durable instead of stacking remotes"],"exampleFix":"# before\n<secondary>\n  @type forward\n  <server> host backup1 </server>\n  <secondary>\n    @type secondary_file\n    directory /var/log/fluent/backup\n  </secondary>\n</secondary>\n\n# after\n<secondary>\n  @type secondary_file\n  directory /var/log/fluent/backup\n</secondary>","handlingStrategy":"validation","validationCode":"fluentd --dry-run -c /etc/fluent/fluent.conf","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One level of `<secondary>` only — no chains","For multi-tier durability make the secondary local (secondary_file) and ship its files with another pipeline","Lint configs for `<secondary>` appearing twice nested"],"tags":["fluentd","secondary","configuration","nesting"],"backgroundTag":"config-validation-failed","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}