puppetlabs/puppet · error · Puppet::Settings::ValidationError
Invalid duration format '%{value}' for parameter: %{name}
Error message
Invalid duration format '%{value}' for parameter: %{name} What it means
Puppet::Settings::DurationSetting#munge converts duration settings (runinterval, http_keepalive_timeout, ...) to seconds. Accepted inputs are Integers/nil or Strings matching ^(\d+)(y|d|h|m|s)?$ — a number plus at most ONE single-letter unit. Multi-unit strings (1h30m), decimals (1.5h), negatives, spaces (90 s), or long unit names (10minutes, 5min, 500ms) raise Puppet::Settings::ValidationError.
Source
Thrown at lib/puppet/settings/duration_setting.rb:30
"m" => 60,
"s" => 1
}
# A regex describing valid formats with groups for capturing the value and units
FORMAT = /^(\d+)(y|d|h|m|s)?$/
def type
:duration
end
# Convert the value to an integer, parsing numeric string with units if necessary.
def munge(value)
if value.is_a?(Integer) || value.nil?
value
elsif value.is_a?(String) and value =~ FORMAT
::Regexp.last_match(1).to_i * UNITMAP[::Regexp.last_match(2) || 's']
else
raise Puppet::Settings::ValidationError, _("Invalid duration format '%{value}' for parameter: %{name}") % { value: value.inspect, name: @name }
end
end
end
View on GitHub (pinned to e227c27540)
Solutions
- Use a bare integer of seconds (runinterval = 600) or number + single letter: 10m, 2h, 1d, 1y.
- Convert compound durations yourself before writing config (1h30m -> 90m or 5400).
- Milliseconds are not supported — convert ms values to seconds (500ms -> 0.5 is invalid; use 1 or restructure).
Example fix
# before (puppet.conf [agent]) runinterval = 10minutes # after runinterval = 10m
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, "bad duration #{v.inspect}" unless v.is_a?(Integer) || v.to_s.match?(/^(\d+)(y|d|h|m|s)?$/)
Puppet.settings[:runinterval] = v Type guard
valid_duration = ->(v) { v.is_a?(Integer) || v.to_s.match?(/^(\d+)(y|d|h|m|s)?$/) } Try / catch
begin
Puppet.settings[:runinterval] = v
rescue Puppet::Settings::ValidationError => e
raise unless e.message.include?('duration')
Puppet.err("#{e.message} — use integer seconds or Ns/Nm/Nh/Nd/Ny")
raise
end Prevention
- Use bare seconds (600) or one single-letter unit (10m, 2h, 1d)
- No milliseconds, decimals, negatives, or compound units (1h30m) in duration settings
- Convert systemd/nginx-style durations before writing them into puppet.conf
When it happens
Trigger: puppet.conf `runinterval = 10minutes`, `runinterval = 1.5h`, `runinterval = 1h30m`, or `runinterval = 500ms`; programmatic Puppet.settings[:runinterval] = '90 s'; values copied from systemd/nginx configs.
Common situations: Expecting millisecond support (the smallest unit is s); copying time formats across tools; templated configs generating compound durations.
Related errors
- Invalid run mode '#{mode}'
- Invalid autosign value %{value}: must be 'true'/'false' or a
- Invalid value '%{value}' for boolean parameter: %{name}
- Invalid certificate revocation value %{value}: must be one o
- Global option %{option} does not exist in Puppet.settings
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/bf7e0ae3c1459f15.
Report an issue: GitHub.