puppetlabs/puppet · error · Puppet::Error
Error while parsing 'fromdate'
Error message
Error while parsing 'fromdate'
What it means
The FileBucket list action parses the fromdate option with Ruby's Time.parse; the default is '0:0:0 1-1-1970'. If the string is not a recognized time expression, the ArgumentError is re-raised as Puppet::Error "Error while parsing 'fromdate'". Note that todate is parsed first, so a bad todate surfaces before this one.
Source
Thrown at lib/puppet/indirector/file_bucket_file/file.rb:60
end
end
def list(request)
if request.remote?
raise Puppet::Error, _("Listing remote file buckets is not allowed")
end
fromdate = request.options[:fromdate] || "0:0:0 1-1-1970"
todate = request.options[:todate] || Time.now.strftime("%F %T")
begin
to = Time.parse(todate)
rescue ArgumentError
raise Puppet::Error, _("Error while parsing 'todate'")
end
begin
from = Time.parse(fromdate)
rescue ArgumentError
raise Puppet::Error, _("Error while parsing 'fromdate'")
end
# Setting hash's default value to [], needed by the following loop
bucket = Hash.new { [] }
msg = ''.dup
# Get all files with mtime between 'from' and 'to'
Pathname.new(request.options[:bucket_path]).find { |item|
next unless item.file? and item.basename.to_s == "paths"
filenames = item.read.strip.split("\n")
filestat = Time.parse(item.stat.mtime.to_s)
next unless from <= filestat and filestat <= to
filenames.each do |filename|
bucket[filename] += [[item.stat.mtime, item.parent.basename]]
end
}
# Sort the results
bucket.each { |_filename, contents|View on GitHub (pinned to e227c27540)
Solutions
- Use an explicit format: --fromdate 'YYYY-MM-DD HH:MM:SS', e.g. '1970-01-01 00:00:00'.
- Omit --fromdate; it defaults to '0:0:0 1-1-1970' (epoch), which lists everything up to todate.
- Quote the whole value in the shell.
- Pre-validate scripted dates with Time.parse in a rescue block.
Example fix
# before puppet filebucket list --fromdate 2024-13-01 --todate "2024-12-31" # Error: Error while parsing 'fromdate' # after puppet filebucket list --fromdate "2024-01-01 00:00:00" --todate "2024-12-31 23:59:59"
Defensive patterns
Strategy: validation
Validate before calling
require 'time' def parseable_date?(value) Time.parse(value) true rescue ArgumentError false end abort 'invalid --fromdate, expected YYYY-MM-DD HH:MM:SS' unless parseable_date?(fromdate)
Prevention
- Standardize on ISO 8601 'YYYY-MM-DD HH:MM:SS' in all tooling.
- Omit --fromdate when you mean 'everything up to todate' (default is epoch).
- Quote date arguments so shells cannot split them.
When it happens
Trigger: Passing an unparseable --fromdate to 'puppet filebucket list': values like 'yesturday', '2024-02-30', or fragments of an unquoted date string.
Common situations: Locale-ambiguous or day/month-swapped dates; empty shell variables expanding to nothing or garbage; dates built by string concatenation in wrapper scripts.
Related errors
- Error while parsing 'todate'
- Need exactly two arguments: filebucket diff <file_a> <file_b
- Could not back up %{file}: %{detail}
- Diff is not supported on this platform
- Please provide a file or checksum to diff with
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/fa27da0400fbc7e0.
Report an issue: GitHub.