puppetlabs/puppet · error · Puppet::Error
Invalid 'hasstatus' value #{value.inspect}
Error message
Invalid 'hasstatus' value #{value.inspect} What it means
The init service provider's hasstatus= setter accepts exactly true, "true", false, or "false"; any other Ruby object raises Puppet::Error. This setter sits below the type-level validation of the hasstatus property, so it is normally only hit through programmatic use: provider instances built by hand, custom providers, or tests that poke @parameters directly instead of going through the property system.
Source
Thrown at lib/puppet/provider/service/init.rb:115
next if name =~ /^\./
next if exclude.include? name
next if Puppet::FileSystem.directory?(fullpath)
next unless Puppet::FileSystem.executable?(fullpath)
next unless is_init?(fullpath)
instances << new(:name => name, :path => path, :hasstatus => true)
end
end
instances
end
# Mark that our init script supports 'status' commands.
def hasstatus=(value)
case value
when true, "true"; @parameters[:hasstatus] = true
when false, "false"; @parameters[:hasstatus] = false
else
raise Puppet::Error, "Invalid 'hasstatus' value #{value.inspect}"
end
end
# Where is our init script?
def initscript
@initscript ||= search(@resource[:name])
end
def paths
@paths ||= @resource[:path].find_all do |path|
if Puppet::FileSystem.directory?(path)
true
else
if Puppet::FileSystem.exist?(path)
debug "Search path #{path} is not a directory"
else
debug "Search path #{path} does not exist"
endView on GitHub (pinned to e227c27540)
Solutions
- Pass booleans or their exact string forms: true, false, 'true', 'false'
- Convert symbols before assignment: value.to_s == 'true' style normalization
- Set hasstatus via the resource property in manifests (hasstatus => true) instead of mutating provider parameters
Example fix
# before provider.hasstatus = @resource[:hasstatus] # :true symbol -> raises # after provider.hasstatus = (@resource[:hasstatus].to_s == 'true')
Defensive patterns
Strategy: type-guard
Type guard
# Ruby guard before calling the setter
def valid_hasstatus?(value)
[true, false, 'true', 'false'].include?(value)
end
raise ArgumentError, "bad hasstatus: #{value.inspect}" unless valid_hasstatus?(v)
provider.hasstatus = v Try / catch
begin provider.hasstatus = v rescue Puppet::Error provider.hasstatus = v.to_s == 'true' # normalize and retry once end
Prevention
- Remember @resource[:hasstatus] is the symbol :true at provider level — convert with .to_s before assigning
- Prefer setting hasstatus as a resource property in manifests; the type layer validates values for you
- Cover the setter in provider specs with both booleans and string forms to catch regressions
When it happens
Trigger: Calling provider.hasstatus = with a symbol (:true/:false), integer, or nil — for example provider.new(:name => 'x', :hasstatus => :true) in rspec-puppet tests, or a custom provider copying unconverted symbol values from the resource (@resource[:hasstatus] is the symbol :true at that layer, not the boolean true).
Common situations: Writing provider specs or custom service providers that pass @resource[:hasstatus] straight through; using puppet resource service <name> hasstatus=<odd value>; DSL-level mistakes are usually caught earlier by the property validation, so this is chiefly a developer-facing error.
Related errors
- Could not find init script for '#{name}'
- Unable to verify the SSL certificate at %{uri}
- Unknown service #{name}
- Unrecognized value for request 'merge' parameter: '%{merge}'
- #{self.class.name} must specify a path for daemon directory
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/0fe999fb9a25b360.
Report an issue: GitHub.