{"record":{"id":"e877acc6e16a891e","repo":"fluent/fluentd","slug":"renew-record-must-be-true-to-use-keep-keys","errorCode":null,"errorMessage":"`renew_record` must be true to use `keep_keys`","messagePattern":"`renew_record` must be true to use `keep_keys`","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/filter_record_transformer.rb","lineNumber":59,"sourceCode":"    desc 'When set to true, the full Ruby syntax is enabled in the ${...} expression.'\n    config_param :enable_ruby, :bool, default: false\n    desc 'Use original value type.'\n    config_param :auto_typecast, :bool, default: true\n\n    def configure(conf)\n      super\n\n      map = {}\n      # <record></record> directive\n      conf.elements.select { |element| element.name == 'record' }.each do |element|\n        element.each_pair do |k, v|\n          element.has_key?(k) # to suppress unread configuration warning\n          map[k] = parse_value(v)\n        end\n      end\n\n      if @keep_keys\n        raise Fluent::ConfigError, \"`renew_record` must be true to use `keep_keys`\" unless @renew_record\n      end\n\n      @key_deleters = if @remove_keys\n                        @remove_keys.map { |k| record_accessor_create(k) }\n                      end\n\n      placeholder_expander_params = {\n        log: log,\n        auto_typecast: @auto_typecast,\n      }\n      @placeholder_expander =\n        if @enable_ruby\n          # require utilities which would be used in ruby placeholders\n          require 'pathname'\n          require 'uri'\n          require 'cgi/escape'\n          RubyPlaceholderExpander.new(placeholder_expander_params)\n        else","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/filter_record_transformer.rb#L41-L77","documentation":"record_transformer rebuilds a record from <record> placeholders. keep_keys lists keys from the original record to carry over, which only has meaning when renew_record true (the new record replaces the old one); without renewal the original fields are already kept. At configure time, specifying keep_keys while renew_record is false (its default) raises Fluent::ConfigError '`renew_record` must be true to use `keep_keys`', so the config never loads.","triggerScenarios":"A record_transformer block containing keep_keys [...] without renew_record true.","commonSituations":"Operators adding keep_keys to selectively preserve fields without realizing it implies full record renewal; configs migrated from examples that omitted the renew_record line; intention was actually remove_keys (which works without renewal).","solutions":["Add renew_record true when you really want a fresh record keeping only the listed keys.","Or drop keep_keys and use remove_keys [...] to strip fields from the original record (no renewal needed).","Validate with fluentd --dry-run before deploying."],"exampleFix":"# before\n<filter app.**>\n  @type record_transformer\n  keep_keys [\"time\",\"host\"]\n  <record>\n    hostname ${host}\n  </record>\n</filter>\n# after\n<filter app.**>\n  @type record_transformer\n  renew_record true\n  keep_keys [\"time\",\"host\"]\n  <record>\n    hostname ${host}\n  </record>\n</filter>","handlingStrategy":"validation","validationCode":"# config lint: keep_keys requires renew_record\nif conf =~ /keep_keys/ && conf !~ /renew_record\\s+true/\n  abort 'record_transformer: keep_keys without renew_record true'\nend\n# authoritative check: fluentd --dry-run -c /etc/fluent/fluent.conf","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::Plugin.new_filter('record_transformer').configure(conf)\nrescue Fluent::ConfigError => e\n  abort \"record_transformer config rejected: #{e.message}\"\nend","preventionTips":["Remember keep_keys implies rebuilding the record: always pair with renew_record true.","Use remove_keys when you want to strip fields without renewal.","Dry-run configs in CI to catch param-dependency errors."],"tags":["fluentd","ruby","record-transformer","configuration","param-dependency"],"backgroundTag":"config-param-dependency-violation","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}