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

  1. Read the message tail - it enumerates the valid values and regex patterns for that attribute
  2. Run puppet describe -s <type> to see the allowed values for each attribute
  3. Fix the value (usually lowercase: present, running, installed, latest, absent)
  4. 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

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


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/a75185826db19502. Report an issue: GitHub.