{"record":{"id":"8946f89e25b5ff03","repo":"fluent/fluentd","slug":"empty-value-is-specified-in-fields-parameter","errorCode":null,"errorMessage":"empty value is specified in fields parameter","messagePattern":"empty value is specified in fields parameter","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/formatter_csv.rb","lineNumber":58,"sourceCode":"      end\n\n      def csv_thread_key\n        csv_cacheable? ? \"#{owner.plugin_id}_csv_formatter_#{@usage}_csv\" : nil\n      end\n\n      def csv_for_thread\n        if csv_cacheable?\n          Thread.current[csv_thread_key] ||= CSV.new(\"\".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)\n        else\n          CSV.new(\"\".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)\n        end\n      end\n\n      def configure(conf)\n        super\n\n        @fields = fields.select{|f| !f.empty? }\n        raise ConfigError, \"empty value is specified in fields parameter\" if @fields.empty?\n\n        if @fields.any? { |f| record_accessor_nested?(f) }\n          @accessors = @fields.map { |f| record_accessor_create(f) }\n          mformat = method(:format_with_nested_fields)\n          singleton_class.module_eval do\n            define_method(:format, mformat)\n          end\n        end\n\n        @generate_opts = {col_sep: @delimiter, force_quotes: @force_quotes, headers: @fields,\n                          row_sep: @add_newline ? :auto : \"\".force_encoding(Encoding::ASCII_8BIT)}\n      end\n\n      def format(tag, time, record)\n        csv = csv_for_thread\n        line = (csv << record).string.dup\n        # Need manual cleanup because CSV writer doesn't provide such method.\n        csv.rewind","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/formatter_csv.rb#L40-L76","documentation":"The CSV formatter formats each record according to the fields array. During configure, empty-string entries are filtered out (fields.select{|f| !f.empty? }); if nothing remains the plugin raises ConfigError 'empty value is specified in fields parameter'. This fires both when fields is omitted entirely and when every entry is an empty string.","triggerScenarios":"A <format> @type csv block with no fields param, fields set to an empty string, or fields whose entries are all empty (e.g. stray commas produce empty entries but also at least one non-empty one, which would NOT raise).","commonSituations":"Enabling CSV output for out_file/file buffers without specifying columns; templated configs where the fields variable renders empty; commented-out fields lines.","solutions":["Set fields to the explicit column list, e.g. fields [\"time\",\"level\",\"message\"].","If fields comes from a template/variable, assert it is non-empty before rendering the config.","Validate with fluentd --dry-run to catch it at deploy time."],"exampleFix":"# before\n<match app.**>\n  @type file\n  <format>\n    @type csv\n  </format>\n</match>\n# after\n<match app.**>\n  @type file\n  <format>\n    @type csv\n    fields [\"time\",\"level\",\"message\"]\n  </format>\n</match>","handlingStrategy":"validation","validationCode":"# config lint: csv formatter must end up with at least one non-empty field\nfields = conf_fields_for_csv_format.compact.map(&:strip).reject(&:empty?)\nabort 'csv formatter: fields is empty' if fields.empty?\n# authoritative: fluentd --dry-run -c /etc/fluent/fluent.conf","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::Plugin.new_formatter('csv').configure(conf)\nrescue Fluent::ConfigError => e\n  abort \"csv formatter config rejected: #{e.message}\" # 'empty value is specified in fields parameter'\nend","preventionTips":["Always declare fields for @type csv format sections.","If fields is templated, assert the rendered value is non-empty in CI.","Dry-run the config after every change."],"tags":["fluentd","ruby","formatter-csv","configuration","missing-param"],"backgroundTag":"missing-required-config-param","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}