{"record":{"id":"916bbf23c0295a14","repo":"puppetlabs/puppet","slug":"password-warning-days-must-be-provided-as-a-number","errorCode":null,"errorMessage":"Password warning days must be provided as a number.","messagePattern":"Password warning days must be provided as a number\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/user.rb","lineNumber":335,"sourceCode":"        end\n      end\n    end\n\n    newproperty(:password_warn_days, :required_features => :manages_password_age) do\n      desc \"The number of days before a password is going to expire (see the maximum password age) during which the user should be warned.\"\n\n      munge do |value|\n        case value\n        when String\n          Integer(value)\n        else\n          value\n        end\n      end\n\n      validate do |value|\n        if value.to_s !~ /^-?\\d+$/\n          raise ArgumentError, \"Password warning days must be provided as a number.\"\n        end\n      end\n    end\n\n    newproperty(:groups, :parent => Puppet::Property::List) do\n      desc \"The groups to which the user belongs.  The primary group should\n        not be listed, and groups should be identified by name rather than by\n        GID.  Multiple groups should be specified as an array.\"\n\n      validate do |value|\n        if value =~ /^\\d+$/\n          raise ArgumentError, _(\"Group names must be provided, not GID numbers.\")\n        end\n        raise ArgumentError, _(\"Group names must be provided as an array, not a comma-separated list.\") if value.include?(\",\")\n        raise ArgumentError, _(\"Group names must not be empty. If you want to specify \\\"no groups\\\" pass an empty array\") if value.empty?\n      end\n\n      def change_to_s(currentvalue, newvalue)","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/user.rb#L317-L353","documentation":"Raised by the validate block of the `password_warn_days` property on the Puppet `user` type (shadow password aging: days before expiry during which the user is warned). The property requires value.to_s to match /^-?\\d+$/, so any value whose string form is not a plain, optionally signed integer is rejected with this ArgumentError. A String that does pass (e.g. \"7\") is additionally converted with Integer(value) by the munge block. The property also requires the provider feature :manages_password_age (useradd with ruby-shadow, Solaris user_role_add, AIX).","triggerScenarios":"Declaring `user { 'bob': password_warn_days => 'soon' }`, `=> 7.5`, `=> '7 days'`, or an empty string; supplying the value from Hiera as a float-string or a string with units/whitespace; setting it on a platform whose selected provider lacks :manages_password_age also fails property setup.","commonSituations":"Hiera YAML storing \"7 days\" or \"7.0\" instead of 7; profile classes interpolating text into the value; copy-pasting output of `chage -l`; unit suffixes added by well-meaning data owners.","solutions":["Pass a plain integer: `password_warn_days => 7` (or a numeric string like '7')","Fix the Hiera/YAML data to store an integer without units or quotes","Type the class parameter as Optional[Integer] so Puppet 4 data types reject bad values before the resource compiles","If you need the property, ensure a provider with manages_password_age is used (ruby-shadow installed for useradd)"],"exampleFix":"# before\nuser { 'bob':\n  ensure               => present,\n  password_warn_days  => '7 days',\n}\n\n# after\nuser { 'bob':\n  ensure               => present,\n  password_warn_days  => 7,\n}","handlingStrategy":"validation","validationCode":"# Puppet DSL: catch it at data-typing time in the profile\nclass profile::users (\n  Optional[Integer] $password_warn_days = undef,\n) {\n  user { 'bob': password_warn_days => $password_warn_days }\n}\n\n# Ruby API: pre-check before creating the resource\nraw = params[:password_warn_days]\nraise ArgumentError, 'password_warn_days must be an integer' unless raw.nil? || raw.to_s.match?(/\\A-?\\d+\\z/)","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Type.type(:user).new(name: 'bob', password_warn_days: raw)\nrescue ArgumentError => e\n  # e.message == \"Password warning days must be provided as a number.\"\n  raise Puppet::Error, \"bad password_warn_days data: #{e.message}\"\nend","preventionTips":["Declare class parameters holding this value as Optional[Integer] so the Puppet 4 type system rejects bad data at compile time","Keep numeric Hiera values as YAML integers, not strings with units","Run puppet parser validate / puppet epp validate in CI over role and profile code"],"tags":["puppet","user-resource","password-aging","argument-validation"],"backgroundTag":"numeric-field-validation","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}