{"record":{"id":"fa27da0400fbc7e0","repo":"puppetlabs/puppet","slug":"error-while-parsing-fromdate","errorCode":null,"errorMessage":"Error while parsing 'fromdate'","messagePattern":"Error while parsing 'fromdate'","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/indirector/file_bucket_file/file.rb","lineNumber":60,"sourceCode":"      end\n    end\n\n    def list(request)\n      if request.remote?\n        raise Puppet::Error, _(\"Listing remote file buckets is not allowed\")\n      end\n\n      fromdate = request.options[:fromdate] || \"0:0:0 1-1-1970\"\n      todate = request.options[:todate] || Time.now.strftime(\"%F %T\")\n      begin\n        to = Time.parse(todate)\n      rescue ArgumentError\n        raise Puppet::Error, _(\"Error while parsing 'todate'\")\n      end\n      begin\n        from = Time.parse(fromdate)\n      rescue ArgumentError\n        raise Puppet::Error, _(\"Error while parsing 'fromdate'\")\n      end\n      # Setting hash's default value to [], needed by the following loop\n      bucket = Hash.new { [] }\n      msg = ''.dup\n      # Get all files with mtime between 'from' and 'to'\n      Pathname.new(request.options[:bucket_path]).find { |item|\n        next unless item.file? and item.basename.to_s == \"paths\"\n\n        filenames = item.read.strip.split(\"\\n\")\n        filestat = Time.parse(item.stat.mtime.to_s)\n        next unless from <= filestat and filestat <= to\n\n        filenames.each do |filename|\n          bucket[filename] += [[item.stat.mtime, item.parent.basename]]\n        end\n      }\n      # Sort the results\n      bucket.each { |_filename, contents|","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/indirector/file_bucket_file/file.rb#L42-L78","documentation":"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.","triggerScenarios":"Passing an unparseable --fromdate to 'puppet filebucket list': values like 'yesturday', '2024-02-30', or fragments of an unquoted date string.","commonSituations":"Locale-ambiguous or day/month-swapped dates; empty shell variables expanding to nothing or garbage; dates built by string concatenation in wrapper scripts.","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."],"exampleFix":"# before\npuppet filebucket list --fromdate 2024-13-01 --todate \"2024-12-31\"\n# Error: Error while parsing 'fromdate'\n\n# after\npuppet filebucket list --fromdate \"2024-01-01 00:00:00\" --todate \"2024-12-31 23:59:59\"","handlingStrategy":"validation","validationCode":"require 'time'\n\ndef parseable_date?(value)\n  Time.parse(value)\n  true\nrescue ArgumentError\n  false\nend\n\nabort 'invalid --fromdate, expected YYYY-MM-DD HH:MM:SS' unless parseable_date?(fromdate)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["puppet","filebucket","date-parsing","cli-arguments","input-validation"],"backgroundTag":"invalid-date-format","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}