puppetlabs/puppet · error · ArgumentError
Tries must be an integer >= 1
Error message
Tries must be an integer >= 1
What it means
After munging, the exec type enforces `raise ... if value < 1`, so any syntactically valid integer of zero or below raises ArgumentError 'Tries must be an integer >= 1'. At least one execution attempt must happen, so 0 or negative retry counts are meaningless.
Source
Thrown at lib/puppet/type/exec.rb:360
defaultto 300
end
newparam(:tries) do
desc "The number of times execution of the command should be tried.
This many attempts will be made to execute the command until an
acceptable return code is returned. Note that the timeout parameter
applies to each try rather than to the complete set of tries."
munge do |value|
if value.is_a?(String)
unless value =~ /^\d+$/
raise ArgumentError, _("Tries must be an integer")
end
value = Integer(value)
end
raise ArgumentError, _("Tries must be an integer >= 1") if value < 1
value
end
defaultto 1
end
newparam(:try_sleep) do
desc "The time to sleep in seconds between 'tries'."
munge do |value|
if value.is_a?(String)
unless value =~ /^[-\d.]+$/
raise ArgumentError, _("try_sleep must be a number")
end
value = Float(value)
endView on GitHub (pinned to e227c27540)
Solutions
- Use 1 or higher; 1 is the default and means a single attempt.
- If the intent is 'no retries', omit `tries` entirely instead of using 0.
- Clamp computed values: `tries => max(1, $computed)`.
- Fail early in the manifest: `assert_type(Integer[1, default], $tries)`.
Example fix
// before
exec { 'retry_thing':
command => '/opt/app/job.sh',
tries => 0,
}
// after: omit tries (default 1) or set >= 1
exec { 'retry_thing':
command => '/opt/app/job.sh',
tries => 3,
} Defensive patterns
Strategy: validation
Validate before calling
// Puppet
unless $tries =~ Integer and $tries >= 1 {
fail("exec: tries must be >= 1, got '${tries}'")
} Type guard
def positive_tries?(v) n = v.is_a?(Integer) ? v : (v.to_i if v.is_a?(String) && v.match?(/\A\d+\z/)) !n.nil? && n >= 1 end
Prevention
- Omit tries when you want a single attempt (default 1).
- Clamp computed values: max(1, $n).
- Use assert_type(Integer[1, default], $tries) to fail at compile time.
- Remember tries counts total attempts, not retries.
When it happens
Trigger: `tries => 0`, `tries => -2`, or strings '0'/'00' (digit-only, so they pass the regex, then fail the >= 1 check); computed values from Hiera or arithmetic that evaluate to 0 on some nodes.
Common situations: Using 0 to mean 'disable retrying' (it actually requests zero attempts); computing tries as a difference without a floor; environment-specific Hiera overrides setting 0 in dev tiers.
Related errors
- Tries must be an integer
- try_sleep cannot be a negative number
- Command must be a String or Array<String>, got value of clas
- Invalid environment setting '%{value}'
- The umask specification is invalid: %{value}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/b1ae0f75dc5e314d.
Report an issue: GitHub.