puppetlabs/puppet · error · ArgumentError

Invalid value %{value}.

Error message

Invalid value %{value}.

What it means

`unless_uid` on the resources metatype excludes specific UIDs from purging. Its munge (lib/puppet/type/resources.rb:87) wraps non-array input, flattens, and accepts only Integers and Strings convertible with Integer(); anything else (symbols, hashes, floats, non-numeric words) raises ArgumentError "Invalid value".

Source

Thrown at lib/puppet/type/resources.rb:87

      end
    }
  end

  newparam(:unless_uid) do
    desc 'This keeps specific uids or ranges of uids from being purged when purge is true.
      Accepts integers, integer strings, and arrays of integers or integer strings.
      To specify a range of uids, consider using the range() function from stdlib.'

    munge do |value|
      value = [value] unless value.is_a? Array
      value.flatten.collect do |v|
        case v
        when Integer
          v
        when String
          Integer(v)
        else
          raise ArgumentError, _("Invalid value %{value}.") % { value: v.inspect }
        end
      end
    end
  end

  WINDOWS_SYSTEM_SID_REGEXES =
    # Administrator, Guest, Domain Admins, Schema Admins, Enterprise Admins.
    # https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems
    [/S-1-5-21.+-500/, /S-1-5-21.+-501/, /S-1-5-21.+-512/, /S-1-5-21.+-518/,
     /S-1-5-21.+-519/]

  def check(resource)
    @checkmethod ||= "#{self[:name]}_check"
    @hascheck ||= respond_to?(@checkmethod)
    if @hascheck
      send(@checkmethod, resource)
    else
      true

View on GitHub (pinned to e227c27540)

Solutions

  1. Pass integers, integer strings, or arrays of those, e.g. unless_uid => [0, 1, 999]
  2. To exclude by name, resolve the account to its UID first (e.g. with the puppetslabs/stdlib dig or custom fact)
  3. Build ranges with stdlib's range() function so you get an array of integers

Example fix

# before
resources { 'user':
  purge      => true,
  unless_uid => ['root', 'daemon'],
}

# after
resources { 'user':
  purge      => true,
  unless_uid => [0, 1],
}
Defensive patterns

Strategy: validation

Validate before calling

$u = $unless_uid ? { Undef => [], default => any2array($unless_uid) }
if $u.filter |$v| { $v !~ /^\d+$/ }.size > 0 {
  fail('unless_uid accepts only integers or integer strings')
}

Type guard

def valid_unless_uid?(v)
  vals = v.is_a?(Array) ? v.flatten : [v]
  vals.all? { |x| x.is_a?(Integer) || (x.is_a?(String) && x =~ /\A\d+\z/) }
end

Try / catch

begin
  Puppet::Type.type(:resources).new(name: 'user', purge: true, unless_uid: ['root'])
rescue ArgumentError => e
  raise unless e.message.include?('Invalid value')
  # map names to UIDs and rebuild
end

Prevention

When it happens

Trigger: `resources { 'user': purge => true, unless_uid => 'root' }` (names are not UIDs); `unless_uid => [0, '1', :five]`; `unless_uid => 5.5`; strings like 'all' or 'system'.

Common situations: Trying to protect accounts by name instead of UID; mixing symbol values from YAML/psych loads; passing stdlib range() output of the wrong shape.

Related errors


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