{"record":{"id":"a75185826db19502","repo":"puppetlabs/puppet","slug":"invalid-value-value","errorCode":null,"errorMessage":"Invalid value %{value}.","messagePattern":"Invalid value %(.+?)\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parameter/value_collection.rb","lineNumber":191,"sourceCode":"  # @api private\n  #\n  def regexes\n    @regexes.collect { |r| r.name.inspect }\n  end\n\n  # Validates the given value against the set of valid literal values and regular expressions.\n  # @raise [ArgumentError] if the value is not accepted\n  # @return [void]\n  # @api private\n  #\n  def validate(value)\n    return if empty?\n\n    unless @values.detect { |_name, v| v.match?(value) }\n      str = _(\"Invalid value %{value}.\") % { value: value.inspect }\n      str += \" \" + _(\"Valid values are %{value_list}.\") % { value_list: values.join(\", \") } unless values.empty?\n      str += \" \" + _(\"Valid values match %{pattern}.\") % { pattern: regexes.join(\", \") } unless regexes.empty?\n      raise ArgumentError, str\n    end\n  end\n\n  # Returns a valid value matcher (a literal or regular expression)\n  # @todo This looks odd, asking for an instance that matches a symbol, or an instance that has\n  #   a regexp. What is the intention here? Marking as api private...\n  #\n  # @return [Puppet::Parameter::Value] a valid value matcher\n  # @api private\n  #\n  def value(name)\n    @values[name]\n  end\n\n  # @return [Array<Symbol>] Returns a list of valid literal values.\n  # @see regexes\n  # @api private\n  #","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parameter/value_collection.rb#L173-L209","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nservice { 'httpd': ensure => 'runing' }\n\n# after\nservice { 'httpd': ensure => 'running' }","handlingStrategy":"validation","validationCode":"attr = Puppet::Type.type(:service).attrclass(:ensure)\nbegin\n  attr.validate(value)\nrescue ArgumentError => e\n  # e.message lists valid values / patterns\nend","typeGuard":null,"tryCatchPattern":"begin\n  catalog = compiler.compile\nrescue ArgumentError => e\n  retry_values_from_message(e.message) if e.message.start_with?('Invalid value')\nend","preventionTips":["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"],"tags":["puppet","dsl","resource","validation","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}