{"record":{"id":"9d4f286925d74fb1","repo":"fluent/fluentd","slug":"bug-msg","errorCode":null,"errorMessage":"BUG: #{msg}","messagePattern":"BUG: #(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/service_discovery/manager.rb","lineNumber":89,"sourceCode":"            @discoveries.each do |d|\n              d.__send__(mth)\n            end\n          end\n        end\n\n        def run_once\n          # Don't care race in this loop intentionally\n          s = @queue.size\n\n          if s == 0\n            return\n          end\n\n          s.times do\n            msg = @queue.pop\n\n            unless msg.is_a?(Fluent::Plugin::ServiceDiscovery::DiscoveryMessage)\n              @log.warn(\"BUG: #{msg}\")\n              next\n            end\n\n            begin\n              handle_message(msg)\n            rescue => e\n              @log.error(e)\n            end\n          end\n\n          rebalance\n        end\n\n        def rebalance\n          @load_balancer.rebalance(services)\n        end\n\n        def select_service(&block)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/service_discovery/manager.rb#L71-L107","documentation":"ServiceDiscovery::Manager#run_once drains its queue of discovery events; every element is expected to be a Fluent::Plugin::ServiceDiscovery::DiscoveryMessage. If something else (string, hash, nil) was enqueued, it logs 'BUG: <msg>' and skips it — an internal invariant violation, since only Fluentd code and custom discovery plugins should push into that queue via the documented send_message path.","triggerScenarios":"A custom service_discovery plugin pushing raw objects into the manager's queue instead of building DiscoveryMessage instances; thread-unsafe or experimental monkeypatches around the discovery manager; a Fluentd bug in a specific version's discovery plumbing.","commonSituations":"Writing a bespoke discovery mechanism (consul/etcd-style) as a Fluentd plugin and bypassing the message API; forked Fluentd versions drifting from upstream queue handling.","solutions":["Audit custom service_discovery plugins: enqueue only via the documented API that wraps payloads in ServiceDiscovery::DiscoveryMessage.","Report upstream with the logged payload, plugin list, and full backtrace — stock Fluentd cannot enqueue foreign objects.","Reproduce with third-party discovery plugins disabled to isolate which component pushes invalid messages.","Upgrade to the latest Fluentd patch release."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"# Only ever enqueue DiscoveryMessage-wrapped events into the discovery manager\nFluent::Plugin::ServiceDiscovery::DiscoveryMessage === msg || raise(ArgumentError, 'discovery queue accepts DiscoveryMessage only')","tryCatchPattern":null,"preventionTips":["Custom discovery plugins must push events through the documented send_message API, never raw objects.","Keep discovery manager code un-patched; report foreign-object warnings upstream with the payload."],"tags":["service-discovery","internal-bug","invariant","plugin-api"],"backgroundTag":"unreachable-invariant-violation","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}