{"record":{"id":"f50e99dbd4a24e10","repo":"fluent/fluentd","slug":"invalid-time-format-value-value-error-class","errorCode":null,"errorMessage":"invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}","messagePattern":"invalid time format: value = #(.+?), error_class = #(.+?), error = #(.+?)","errorType":"exception","errorClass":"Fluent::TimeParser::TimeParseError","httpStatus":null,"severity":"error","filePath":"lib/fluent/time.rb","lineNumber":281,"sourceCode":"               else ->(v){ Fluent::EventTime.parse(v) }\n               end\n    end\n\n    # TODO: new cache mechanism using format string\n    def parse(value)\n      unless value.is_a?(String)\n        raise TimeParseError, \"value must be string: #{value}\"\n      end\n\n      if @cache1_key == value\n        return @cache1_time\n      elsif @cache2_key == value\n        return @cache2_time\n      else\n        begin\n          time = @parse.call(value)\n        rescue => e\n          raise TimeParseError, \"invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}\"\n        end\n        @cache1_key = @cache2_key\n        @cache1_time = @cache2_time\n        @cache2_key = value\n        @cache2_time = time\n        return time\n      end\n    end\n    alias :call :parse\n  end\n\n  class NumericTimeParser < TimeParser # to include TimeParseError\n    def initialize(type, localtime = nil, timezone = nil)\n      @cache1_key = @cache1_time = @cache2_key = @cache2_time = nil\n\n      if type == :unixtime\n        define_singleton_method(:parse, method(:parse_unixtime))\n        define_singleton_method(:call, method(:parse_unixtime))","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/time.rb#L263-L299","documentation":"Fluent::TimeParseError raised by TimeParser#parse (lib/fluent/time.rb:281) when the inner strptime/EventTime parse lambda raises for a String input. The message embeds the original value, error class and message, e.g. strptime failing because the text does not match the configured time_format. It is the generic 'string did not match format' error for string time parsing.","triggerScenarios":"A record whose time_key string does not match the configured time_format ('2021/08/20 12:00:00' against %Y-%m-%dT%H:%M:%S%z); a format with %z receiving a timestamp without offset; locales/AM-PM mismatches; calling Fluent::TimeParser.new('%Y-%m-%d').parse('not a date').","commonSituations":"Application changes its log timestamp format after a release; multiple services with different formats shipped to one parser tag; DST/zone abbreviation (%Z) edge cases strptime rejects; copy-pasted time_format missing the %z the data contains.","solutions":["Log one failing value and match time_format exactly to it (test in irb: require 'time'; Time.strptime('value', 'format'))","If formats genuinely vary, switch to time_type mixed with time_format_fallbacks listing each known format","Catch upstream format drift: alert on parser errors, or route unparsable records to a dead-letter tag using a filter/parser's rescue logic instead of dropping"],"exampleFix":"# before\n<parse>\n  @type apache2\n  time_format %Y-%m-%dT%H:%M:%S%z   # logs actually look like: 20/Aug/2021:12:00:00 +0900\n</parse>\n\n# after\n<parse>\n  @type apache2\n  time_format %d/%b/%Y:%H:%M:%S %z\n</parse>","handlingStrategy":"try-catch","validationCode":"# smoke-test the format against a real sample before startup:\nrequire 'time'\nsample = '20/Aug/2021:12:00:00 +0900'\nfmt = '%d/%b/%Y:%H:%M:%S %z'\nTime.strptime(sample, fmt)   # raises ArgumentError if mismatched — fix config before deploy","typeGuard":null,"tryCatchPattern":"begin\n  time = parser.parse(str)\nrescue Fluent::TimeParseError => e\n  # quarantine instead of crash-looping\n  router.emit_stream('app.unparsable', MultiEventStream.new(...))\nend","preventionTips":["Verify time_format against production samples in irb (Time.strptime) when onboarding a source","Use time_type mixed with fallbacks when a tag carries multiple formats","Alert on parser error rates so format drift is caught at the producer"],"tags":["fluentd","time","parser","time-format","runtime"],"backgroundTag":"datetime-parse-failed","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}