{"record":{"id":"23686e87ed39d797","repo":"puppetlabs/puppet","slug":"invalid-value-value-23686e","errorCode":null,"errorMessage":"Invalid value %{value}.","messagePattern":"Invalid value %(.+?)\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/resources.rb","lineNumber":87,"sourceCode":"      end\n    }\n  end\n\n  newparam(:unless_uid) do\n    desc 'This keeps specific uids or ranges of uids from being purged when purge is true.\n      Accepts integers, integer strings, and arrays of integers or integer strings.\n      To specify a range of uids, consider using the range() function from stdlib.'\n\n    munge do |value|\n      value = [value] unless value.is_a? Array\n      value.flatten.collect do |v|\n        case v\n        when Integer\n          v\n        when String\n          Integer(v)\n        else\n          raise ArgumentError, _(\"Invalid value %{value}.\") % { value: v.inspect }\n        end\n      end\n    end\n  end\n\n  WINDOWS_SYSTEM_SID_REGEXES =\n    # Administrator, Guest, Domain Admins, Schema Admins, Enterprise Admins.\n    # https://support.microsoft.com/en-us/help/243330/well-known-security-identifiers-in-windows-operating-systems\n    [/S-1-5-21.+-500/, /S-1-5-21.+-501/, /S-1-5-21.+-512/, /S-1-5-21.+-518/,\n     /S-1-5-21.+-519/]\n\n  def check(resource)\n    @checkmethod ||= \"#{self[:name]}_check\"\n    @hascheck ||= respond_to?(@checkmethod)\n    if @hascheck\n      send(@checkmethod, resource)\n    else\n      true","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/resources.rb#L69-L105","documentation":"`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\".","triggerScenarios":"`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'.","commonSituations":"Trying to protect accounts by name instead of UID; mixing symbol values from YAML/psych loads; passing stdlib range() output of the wrong shape.","solutions":["Pass integers, integer strings, or arrays of those, e.g. unless_uid => [0, 1, 999]","To exclude by name, resolve the account to its UID first (e.g. with the puppetslabs/stdlib dig or custom fact)","Build ranges with stdlib's range() function so you get an array of integers"],"exampleFix":"# before\nresources { 'user':\n  purge      => true,\n  unless_uid => ['root', 'daemon'],\n}\n\n# after\nresources { 'user':\n  purge      => true,\n  unless_uid => [0, 1],\n}","handlingStrategy":"validation","validationCode":"$u = $unless_uid ? { Undef => [], default => any2array($unless_uid) }\nif $u.filter |$v| { $v !~ /^\\d+$/ }.size > 0 {\n  fail('unless_uid accepts only integers or integer strings')\n}","typeGuard":"def valid_unless_uid?(v)\n  vals = v.is_a?(Array) ? v.flatten : [v]\n  vals.all? { |x| x.is_a?(Integer) || (x.is_a?(String) && x =~ /\\A\\d+\\z/) }\nend","tryCatchPattern":"begin\n  Puppet::Type.type(:resources).new(name: 'user', purge: true, unless_uid: ['root'])\nrescue ArgumentError => e\n  raise unless e.message.include?('Invalid value')\n  # map names to UIDs and rebuild\nend","preventionTips":["Convert account names to UIDs before declaring unless_uid","Validate array elements with Puppet data types: Array[Variant[Integer, Pattern[/\\A\\d+\\z/]]]","Use stdlib range() for UID ranges"],"tags":["puppet","purge","user","uid","invalid-value"],"backgroundTag":"invalid-parameter-value","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}