{"record":{"id":"7294d5c7c99dfe21","repo":"puppetlabs/puppet","slug":"unknown-service-name","errorCode":null,"errorMessage":"Unknown service #{name}","messagePattern":"Unknown service #(.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/http/service.rb","lineNumber":47,"sourceCode":"  # @param [<Type>] port optional, the port to connect to\n  #\n  # @return [Puppet::HTTP::Service] an instance of the service type requested\n  #\n  # @api private\n  def self.create_service(client, session, name, server = nil, port = nil)\n    case name\n    when :ca\n      Puppet::HTTP::Service::Ca.new(client, session, server, port)\n    when :fileserver\n      Puppet::HTTP::Service::FileServer.new(client, session, server, port)\n    when :puppet\n      ::Puppet::HTTP::Service::Compiler.new(client, session, server, port)\n    when :puppetserver\n      ::Puppet::HTTP::Service::Puppetserver.new(client, session, server, port)\n    when :report\n      Puppet::HTTP::Service::Report.new(client, session, server, port)\n    else\n      raise ArgumentError, \"Unknown service #{name}\"\n    end\n  end\n\n  # Check if the service named is included in the list of available services.\n  #\n  # @param [Symbol] name\n  #\n  # @return [Boolean]\n  #\n  # @api private\n  def self.valid_name?(name)\n    SERVICE_NAMES.include?(name)\n  end\n\n  # Create a new service. Services should be created by calling `Puppet::HTTP::Session#route_to`.\n  #\n  # @param [Puppet::HTTP::Client] client\n  # @param [Puppet::HTTP::Session] session","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/http/service.rb#L29-L65","documentation":"Puppet::HTTP::Service.create is the factory behind session.create_service and supports exactly five service names: :ca, :fileserver, :puppet (the compiler), :puppetserver, and :report. Any other value raises ArgumentError. Because the dispatch case-matches Symbols, passing a String like 'ca' also falls through to the error.","triggerScenarios":"session.create_service(:puppetdb), :status, or a typo like :reports; create_service('ca') with a String; dynamically built names from config that arrive as Strings.","commonSituations":"Porting from the pre-6.x Puppet::Network::HttpPool/indirection APIs and guessing the new service name; attempting PuppetDB access through puppet's HTTP session instead of the puppetdb client; name-to-symbol conversion missing when service names come from YAML config.","solutions":["Use one of the supported Symbols: :ca, :fileserver, :puppet, :puppetserver, :report.","Validate first with Puppet::HTTP::Service.valid_name?(name) or check Puppet::HTTP::Service::SERVICE_NAMES.","For PuppetDB, use the puppetdb-ruby / pdbclient libraries, not this factory."],"exampleFix":"# before\nservice = session.create_service('puppetdb')\n\n# after\nraise ArgumentError, name unless Puppet::HTTP::Service.valid_name?(name.to_sym)\nservice = session.create_service(name.to_sym)","handlingStrategy":"type-guard","validationCode":"name = name.to_sym\nraise ArgumentError, \"unknown service #{name}\" unless Puppet::HTTP::Service.valid_name?(name)\nservice = session.create_service(name)","typeGuard":"valid_service = ->(n) { Puppet::HTTP::Service::SERVICE_NAMES.include?(n.to_sym) }\nraise ArgumentError, n unless valid_service.call(name)","tryCatchPattern":null,"preventionTips":["Only :ca, :fileserver, :puppet, :puppetserver, :report exist — always pass Symbols.","Convert config-sourced names with .to_sym and validate before creating the service."],"tags":["puppet","http","service","factory","argument-validation"],"backgroundTag":"unknown-service-name","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}