puppetlabs/puppet · error · Puppet::Error
Unknown start type '%{start_type}' for '%{service_name}'
Error message
Unknown start type '%{start_type}' for '%{service_name}' What it means
Raised by service_start_type when the dwStartType from QueryServiceConfigW has no entry in SERVICE_START_TYPES (which maps all five standard values 0-4: boot, system, auto, demand, disabled). As with the state error, the interpolated start_type is nil so the message always prints an empty value, which makes diagnosis confusing. A genuine hit means the SCM returned an out-of-range start type.
Source
Thrown at lib/puppet/util/windows/service.rb:142
# @param [String] service_name name of the service to query
# @return [QUERY_SERVICE_CONFIGW.struct] the configuration of the service
def service_start_type(service_name)
start_type = nil
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_CONFIG) do |service|
query_config(service) do |config|
start_type = SERVICE_START_TYPES[config[:dwStartType]]
end
end
# if the service has type AUTO_START, check if it's a delayed service
if start_type == :SERVICE_AUTO_START
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_CONFIG) do |service|
query_config2(service, SERVICE_CONFIG_DELAYED_AUTO_START_INFO) do |config|
return :SERVICE_DELAYED_AUTO_START if config[:fDelayedAutostart] == 1
end
end
end
if start_type.nil?
raise Puppet::Error, _("Unknown start type '%{start_type}' for '%{service_name}'") % { start_type: start_type.to_s, service_name: service_name }
end
start_type
end
module_function :service_start_type
# Query the configuration of a service using QueryServiceConfigW
# to find its current logon account
#
# @return [String] logon_account account currently set for the service's logon
# in the format "DOMAIN\Account" or ".\Account" if it's a local account
def logon_account(service_name)
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_CONFIG) do |service|
query_config(service) do |config|
return config[:lpServiceStartName].read_arbitrary_wide_string_up_to(Puppet::Util::Windows::ADSI::User::MAX_USERNAME_LENGTH)
end
end
endView on GitHub (pinned to e227c27540)
Solutions
- Check the raw configuration with sc qc <name> to see the actual START_TYPE
- Retry once after a delay if the service was just installed or modified
- Verify ffi gem / Puppet compatibility if multiple services show this
- Report upstream with the service name and sc qc output
Defensive patterns
Strategy: try-catch
Try / catch
begin
Puppet::Util::Windows::Service.service_start_type(name)
rescue Puppet::Error => e
retry if (tries -= 1) > 0 && e.message.include?('Unknown start type')
raise Puppet::Error, "Check raw config: sc qc #{name}"
end Prevention
- Query freshly installed services once more after a short delay
- Verify with sc qc when it reproduces; suspect ffi layout drift if it affects many services
When it happens
Trigger: service_start_type on a driver service whose configuration reports a start type outside 0-4, or corrupted QUERY_SERVICE_CONFIGW data read through FFI. The delayed-autostart probe only runs when the type is SERVICE_AUTO_START, so it cannot rescue this.
Common situations: Querying newly installed or mid-removal services; kernel/boot driver services with unusual configurations; FFI struct layout mismatches after Ruby/ffi upgrades.
Related errors
- Unknown Service state '%{current_state}' for '%{service_name
- Failed to fetch services
- Failed to open a handle to the service
- Failed to open a handle to the service control manager
- The service must be in one of the %{valid_initial_states} st
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/0e28cc3353f11d9a.
Report an issue: GitHub.