{"record":{"id":"d117c977e15a38fa","repo":"fluent/fluentd","slug":"bug-invalid-protocol-name","errorCode":null,"errorMessage":"BUG: invalid protocol name","messagePattern":"BUG: invalid protocol name","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/server.rb","lineNumber":75,"sourceCode":"      PROTOCOLS = [:tcp, :udp, :tls, :unix]\n      CONNECTION_PROTOCOLS = [:tcp, :tls, :unix]\n\n      # server_create_connection(:title, @port) do |conn|\n      #   # on connection\n      #   source_addr = conn.remote_host\n      #   source_port = conn.remote_port\n      #   conn.data do |data|\n      #     # on data\n      #     conn.write resp # ...\n      #     conn.close\n      #   end\n      # end\n      def server_create_connection(title, port, proto: nil, bind: '0.0.0.0', shared: true, backlog: nil, tls_options: nil, **socket_options, &block)\n        proto ||= (@transport_config && @transport_config.protocol == :tls) ? :tls : :tcp\n\n        raise ArgumentError, \"BUG: title must be a symbol\" unless title && title.is_a?(Symbol)\n        raise ArgumentError, \"BUG: port must be an integer\" unless port && port.is_a?(Integer)\n        raise ArgumentError, \"BUG: invalid protocol name\" unless PROTOCOLS.include?(proto)\n        raise ArgumentError, \"BUG: cannot create connection for UDP\" unless CONNECTION_PROTOCOLS.include?(proto)\n\n        raise ArgumentError, \"BUG: tls_options is available only for tls\" if tls_options && proto != :tls\n\n        raise ArgumentError, \"BUG: block not specified which handles connection\" unless block_given?\n        raise ArgumentError, \"BUG: block must have just one argument\" unless block.arity == 1\n\n        if proto == :tcp || proto == :tls\n          socket_options[:linger_timeout] ||= @transport_config&.linger_timeout || 0\n        end\n\n        socket_options[:receive_buffer_size] ||= @transport_config&.receive_buffer_size\n\n        socket_option_validate!(proto, **socket_options)\n        socket_option_setter = ->(sock){ socket_option_set(sock, **socket_options) }\n\n        case proto\n        when :tcp","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/server.rb#L57-L93","documentation":"ArgumentError from server_create_connection in the server plugin helper. The proto: keyword is validated against PROTOCOLS = [:tcp, :udp, :tls, :unix]; anything else - a string 'tcp', :tcp4, :TLS, :sctp - is a caller bug (hence the 'BUG:' prefix), because the helper can only create sockets for the known protocols.","triggerScenarios":"server_create_connection(:my_title, 24224, proto: :tcp4), proto: 'tcp' (string instead of symbol), or a misspelled symbol like :tlss. Note proto defaults to :tls when the plugin's @transport_config protocol is tls, otherwise :tcp, so the invalid value must have been passed explicitly.","commonSituations":"Plugin authors accepting a protocol string from config and passing it through without normalizing; porting code from another library that uses strings or protocol families like :tcp4/:tcp6.","solutions":["Pass one of the symbols :tcp, :udp, :tls, :unix","Normalize config strings first: proto.to_s.downcase.to_sym","When nil is acceptable, omit proto: and let the transport config decide (:tls for <transport tls>, else :tcp)"],"exampleFix":"# before\nserver_create_connection(:in_http, 24224, proto: 'tcp') { |conn| ... }\n\n# after\nserver_create_connection(:in_http, 24224, proto: :tcp) { |conn| ... }","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'proto must be tcp/udp/tls/unix' unless %i[tcp udp tls unix].include?(proto)\nserver_create_connection(title, port, proto: proto) { |conn| ... }","typeGuard":"def valid_server_protocol?(proto)\n  %i[tcp udp tls unix].include?(proto)\nend","tryCatchPattern":"begin\n  server_create_connection(title, port, proto: proto) { |conn| ... }\nrescue ArgumentError => e\n  raise ArgumentError, \"plugin bug: #{e.message} (proto=#{proto.inspect})\"\nend","preventionTips":["Normalize protocol config with .to_s.downcase.to_sym before passing","Freeze the protocol list in one constant shared by validation and calls"],"tags":["fluentd","server","protocol","argument-error","plugin-helper"],"backgroundTag":"invalid-enum-argument","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}