puppetlabs/puppet · warning · Puppet::Error
Unknown service state '%{current_state}' for service '%{reso
Error message
Unknown service state '%{current_state}' for service '%{resource_name}' What it means
Raised by Puppet's Windows service provider when the SCM reports a service state the provider cannot map to stopped/paused/running (mapped: STOPPED/STOP_PENDING, PAUSED/PAUSE_PENDING, RUNNING/CONTINUE_PENDING/START_PENDING). Practically it is an internal guard: the surrounding `rescue => detail` catches it, emits 'Puppet.warning(Status for service ... could not be retrieved: ...)' and falls back to :stopped, so the catalog run continues and the service gets started.
Source
Thrown at lib/puppet/provider/service/windows.rb:104
end
def stop
Puppet::Util::Windows::Service.stop(@resource[:name], timeout: @resource[:timeout])
end
def status
return :stopped unless Puppet::Util::Windows::Service.exists?(@resource[:name])
current_state = Puppet::Util::Windows::Service.service_state(@resource[:name])
state = case current_state
when :SERVICE_STOPPED, :SERVICE_STOP_PENDING
:stopped
when :SERVICE_PAUSED, :SERVICE_PAUSE_PENDING
:paused
when :SERVICE_RUNNING, :SERVICE_CONTINUE_PENDING, :SERVICE_START_PENDING
:running
else
raise Puppet::Error, _("Unknown service state '%{current_state}' for service '%{resource_name}'") % { current_state: current_state, resource_name: @resource[:name] }
end
debug("Service #{@resource[:name]} is #{current_state}")
state
rescue => detail
Puppet.warning("Status for service #{@resource[:name]} could not be retrieved: #{detail}")
:stopped
end
def default_timeout
Puppet::Util::Windows::Service::DEFAULT_TIMEOUT
end
# returns all providers for all existing services and startup state
def self.instances
services = []
Puppet::Util::Windows::Service.services.each do |service_name, _|
services.push(new(:name => service_name))
endView on GitHub (pinned to e227c27540)
Solutions
- Check the accompanying warning for the raw state value and query the node: `Get-Service <name>` / `sc.exe query <name>`.
- If the state is transitional (start/pause pending), wait and re-run; the service usually settles into a mapped state.
- Upgrade the Puppet agent so the SCM helper's state list covers the reported state.
- If the fallback (:stopped) causes an unwanted start, set `ensure => stopped` or use `hasstatus => false`-style manual checks appropriate to your Puppet version.
Defensive patterns
Strategy: fallback
Validate before calling
state = Puppet::Util::Windows::Service.service_state('myapp')
known = %i[SERVICE_STOPPED SERVICE_STOP_PENDING SERVICE_PAUSED SERVICE_PAUSE_PENDING SERVICE_RUNNING SERVICE_CONTINUE_PENDING SERVICE_START_PENDING]
warn 'unmapped SCM state' unless known.include?(state) Type guard
MAPPED_STATES = %i[SERVICE_STOPPED SERVICE_STOP_PENDING SERVICE_PAUSED SERVICE_PAUSE_PENDING SERVICE_RUNNING SERVICE_CONTINUE_PENDING SERVICE_START_PENDING].freeze def puppet_status_symbol(scm_state) case scm_state when :SERVICE_STOPPED, :SERVICE_STOP_PENDING then :stopped when :SERVICE_PAUSED, :SERVICE_PAUSE_PENDING then :paused when :SERVICE_RUNNING, :SERVICE_CONTINUE_PENDING, :SERVICE_START_PENDING then :running end # nil for unmapped end
Prevention
- Remember the built-in fallback: unknown state becomes a warning plus :stopped, so ensure => stopped is the safe declaration for exotic services.
- Verify the real state with `sc.exe query` after runs that emit the warning.
- Keep agent versions aligned with your Windows fleet so mapped state lists stay complete.
When it happens
Trigger: A `status` query returning an unmapped state symbol — e.g., SERVICE_UNKNOWN or a transitional/undocumented state from an older or newer SCM helper — during ensure-sync or an explicit start/stop. The visible symptom is the warning line plus Puppet treating the service as stopped.
Common situations: Puppet version skew between agent and the Windows::Service helper's state list; services in unusual driver/kernel states; tests stubbing service_state with unexpected symbols. Low operational impact because of the built-in fallback.
Related errors
- Unknown start type: %{start_type}
- Will not start disabled service %{resource_name} without man
- Service query for %{parameter_name} failed
- Failed to send the %{control_signal} signal to the service.
- RegisterEventSourceW failed to open Windows eventlog
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/e3aa4868d10fcef9.
Report an issue: GitHub.