{"record":{"id":"6d1baa6874e11905","repo":"fluent/fluentd","slug":"time-slice-format-only-with-y-or-m-is-too-long-6d1baa","errorCode":null,"errorMessage":"time_slice_format only with %Y or %m is too long","messagePattern":"time_slice_format only with %Y or %m is too long","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/compat_parameters.rb","lineNumber":158,"sourceCode":"        hash = compat_parameters_copy_to_subsection_attributes(conf, buffer_params) do |compat_key, value|\n          if compat_key == 'buffer_queue_full_action' && value == 'exception'\n            'throw_exception'\n          else\n            value\n          end\n        end\n\n        chunk_key = default_chunk_key\n\n        if conf.has_key?('time_slice_format')\n          chunk_key = 'time'\n          hash['timekey'] = case conf['time_slice_format']\n                            when /\\%S/ then 1\n                            when /\\%M/ then 60\n                            when /\\%H/ then 3600\n                            when /\\%d/ then 86400\n                            else\n                              raise Fluent::ConfigError, \"time_slice_format only with %Y or %m is too long\"\n                            end\n          if conf.has_key?('localtime') || conf.has_key?('utc')\n            if conf.has_key?('localtime') && conf.has_key?('utc')\n              raise Fluent::ConfigError, \"both of utc and localtime are specified, use only one of them\"\n            elsif conf.has_key?('localtime')\n              hash['timekey_use_utc'] = !(Fluent::Config.bool_value(conf['localtime']))\n            elsif conf.has_key?('utc')\n              hash['timekey_use_utc'] = Fluent::Config.bool_value(conf['utc'])\n            end\n          end\n        else\n          if chunk_key == 'time'\n            hash['timekey'] = 86400 # TimeSliceOutput.time_slice_format default value is '%Y%m%d'\n          end\n        end\n\n        e = Fluent::Config::Element.new('buffer', chunk_key, hash, [])\n        conf.elements << e","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/compat_parameters.rb#L140-L176","documentation":"The CompatParameters helper translates legacy v0.12 buffered-output config into the v0.14 <buffer> model; when time_slice_format is present, it must map the format's coarsest time directive to a timekey: %S→1s, %M→60s, %H→3600s, %d→86400s (compat_parameters.rb:152-158). A format containing only %Y and/or %m (or no time directive at all) describes a period of a month or year, which has no fixed duration and cannot be a chunk timekey, so conversion fails with this Fluent::ConfigError.","triggerScenarios":"A plugin using compat_parameters_convert(conf, :buffer) (or compat_parameters_buffer) whose config sets time_slice_format '%Y%m', '%Y', '%Y-%m', or e.g. '%j' — any value whose case-statement matches none of %S/%M/%H/%d. Hits at configure time, before any records are processed.","commonSituations":"v0.12-era configs migrated forward with monthly-sliced out_file-style paths; operators loosening time_slice_format to reduce file counts; a typo like '%0H' or lowercase '%h' evading every regex branch.","solutions":["Include a day or finer directive in time_slice_format, e.g. '%Y%m%d' (the v0.12 default) which maps to timekey 86400","Better: drop the legacy parameters and configure the v0.14 buffer directly with <buffer time> timekey 2592000 </buffer>-style syntax for month-scale keys where genuinely needed","Check for directive typos: only %S, %M, %H, %d are recognized by the converter","If you maintain the plugin itself, consider warning users about unsupported granularities before the raise"],"exampleFix":"# before\n<match out.**>\n  @type file_with_compat\n  time_slice_format %Y%m      # month granularity: no fixed timekey\n  path /log/${time_slice}.log\n</match>\n# => time_slice_format only with %Y or %m is too long\n\n# after\n<match out.**>\n  @type file_with_compat\n  time_slice_format %Y%m%d   # day granularity -> timekey 86400\n  path /log/${time_slice}.log\n</match>","handlingStrategy":"validation","validationCode":"fmt = '%Y%m%d' # from config\ndirective = fmt[/%(S|M|H|d)/]\nraise 'time_slice_format lacks %S/%M/%H/%d; compat converter cannot derive a timekey' unless directive","typeGuard":null,"tryCatchPattern":"begin\n  plugin.configure(conf)\nrescue Fluent::ConfigError => e\n  if e.message.include?('time_slice_format')\n    abort \"use a day-or-finer directive in time_slice_format, or migrate to <buffer time> timekey\"\n  end\n  raise\nend","preventionTips":["When migrating v0.12 configs, keep time_slice_format at %Y%m%d or finer; coarser slicing has no timekey equivalent","Prefer writing new configs in v0.14 <buffer time> timekey/timekey_wait/timekey_zone syntax and skip the compat layer","Run fluentd --dry-run on migrated configs to catch converter rejects before deploy"],"tags":["fluentd","buffer","compat","v012-migration","time-slice","config-error","startup"],"backgroundTag":"invalid-time-format-directive","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}