puppetlabs/puppet · error · ArgumentError
Invalid value %{value}.
Error message
Invalid value %{value}. What it means
Puppet::Parameter::ValueCollection#validate runs whenever a resource attribute with enumerated values (is/enum list) or regexes is assigned. If the value matches no literal and no regex, ArgumentError 'Invalid value X.' is raised, with the valid value list and/or patterns appended to the message.
Source
Thrown at lib/puppet/parameter/value_collection.rb:191
# @api private
#
def regexes
@regexes.collect { |r| r.name.inspect }
end
# Validates the given value against the set of valid literal values and regular expressions.
# @raise [ArgumentError] if the value is not accepted
# @return [void]
# @api private
#
def validate(value)
return if empty?
unless @values.detect { |_name, v| v.match?(value) }
str = _("Invalid value %{value}.") % { value: value.inspect }
str += " " + _("Valid values are %{value_list}.") % { value_list: values.join(", ") } unless values.empty?
str += " " + _("Valid values match %{pattern}.") % { pattern: regexes.join(", ") } unless regexes.empty?
raise ArgumentError, str
end
end
# Returns a valid value matcher (a literal or regular expression)
# @todo This looks odd, asking for an instance that matches a symbol, or an instance that has
# a regexp. What is the intention here? Marking as api private...
#
# @return [Puppet::Parameter::Value] a valid value matcher
# @api private
#
def value(name)
@values[name]
end
# @return [Array<Symbol>] Returns a list of valid literal values.
# @see regexes
# @api private
#View on GitHub (pinned to e227c27540)
Solutions
- Read the message tail - it enumerates the valid values and regex patterns for that attribute
- Run puppet describe -s <type> to see the allowed values for each attribute
- Fix the value (usually lowercase: present, running, installed, latest, absent)
- If the value should be valid, check the provider supports it in this Puppet version
Example fix
# before
service { 'httpd': ensure => 'runing' }
# after
service { 'httpd': ensure => 'running' } Defensive patterns
Strategy: validation
Validate before calling
attr = Puppet::Type.type(:service).attrclass(:ensure) begin attr.validate(value) rescue ArgumentError => e # e.message lists valid values / patterns end
Try / catch
begin
catalog = compiler.compile
rescue ArgumentError => e
retry_values_from_message(e.message) if e.message.start_with?('Invalid value')
end Prevention
- Run puppet parser validate and module lint/compile tests (rspec-puppet) before deploying
- Use puppet describe -s <type> when writing manifests for enum-valued attributes
- Keep enum values lowercase unless the type documents otherwise
When it happens
Trigger: service { 'httpd': ensure => 'runing' } (typo); package { ensure => 'Installed' } (wrong case); any enum-typed property whose value is not in the type's is list; provider-specific values the loaded provider does not accept.
Common situations: Typos and casing errors in manifests; copy-pasted code for a different provider; Puppet version differences that add/remove allowed values; custom types whose is list changed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Resource instance does not match request key
- Only classes can set 'stage'; normal resources like %{resour
- Unrecognized ADS UserFlags: %{unrecognized_flags}
- --- #{filename}
- Duplicate declaration: %{resource} is already declared; cann
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/a75185826db19502.
Report an issue: GitHub.