puppetlabs/puppet · error · ArgumentError
Password maximum age must be provided as a number.
Error message
Password maximum age must be provided as a number.
What it means
The user type's `password_max_age` property (days before a password must be changed; maps to chage -M) validates its value's string form against /^-?\d+$/ (lib/puppet/type/user.rb:316), mirroring password_min_age. Non-numeric, decimal, or empty values raise ArgumentError.
Source
Thrown at lib/puppet/type/user.rb:316
end
end
end
newproperty(:password_max_age, :required_features => :manages_password_age) do
desc "The maximum number of days a password may be used before it must be changed."
munge do |value|
case value
when String
Integer(value)
else
value
end
end
validate do |value|
if value.to_s !~ /^-?\d+$/
raise ArgumentError, _("Password maximum age must be provided as a number.")
end
end
end
newproperty(:password_warn_days, :required_features => :manages_password_age) do
desc "The number of days before a password is going to expire (see the maximum password age) during which the user should be warned."
munge do |value|
case value
when String
Integer(value)
else
value
end
end
validate do |value|
if value.to_s !~ /^-?\d+$/View on GitHub (pinned to e227c27540)
Solutions
- Pass an integer or integer string, e.g. password_max_age => 90
- Strip units and cast in the wrapper (e.g. Integer(regsubst($v, '^.*(\d+).*$', '')))
- Use undef instead of '' when no maximum applies
Example fix
# before
user { 'alice':
ensure => present,
password_max_age => '90 days',
}
# after
user { 'alice':
ensure => present,
password_max_age => 90,
} Defensive patterns
Strategy: validation
Validate before calling
if $password_max_age != undef and "$password_max_age" !~ /^-?\d+$/ {
fail('password_max_age must be an integer (days)')
} Type guard
def valid_age?(v) v.is_a?(Integer) || (v.is_a?(String) && v =~ /\A-?\d+\z/) end
Try / catch
begin
Puppet::Type.type(:user).new(name: 'a', password_max_age: '90 days')
rescue ArgumentError => e
raise unless e.message.include?('maximum age')
# cast days to Integer and rebuild
end Prevention
- Type policy parameters as Integer in Puppet signatures
- Strip unit suffixes from policy-API data before use
- Set both min/max age from one normalized policy hash
When it happens
Trigger: `password_max_age => '90 days'`; `=> 89.5`; `=> ''`; values pulled from a policy API as 'N days' strings.
Common situations: Password-policy data expressed with units; float ages; empty-string defaults from ENC data.
Related errors
- Password minimum age must be provided as a number.
- Invalid value %{value}
- Invalid value %{value}.
- Invalid hold value %{value}. %{doc}
- Repeat must be a number
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/d8b948903e73cd09.
Report an issue: GitHub.