fluent/fluentd · error · Fluent::ConfigError

empty keys in dot notation

Error message

empty keys in dot notation

What it means

Fluent::ConfigError from Fluent::RecordAccessor when parsing dot notation. An accessor path like $.a.b is split on '.' after stripping '$.'; at least one key (string or integer index) must remain. Paths where every segment is empty, such as '$.', '$..' or '$.[]', yield zero keys and are rejected at accessor-creation time.

Source

Thrown at lib/fluent/plugin_helper/record_accessor.rb:113

          elsif param.start_with?('$[')
            parse_bracket_notation(param)
          else
            param
          end
        end

        def self.parse_dot_notation(param)
          result = []
          keys = param[2..-1].split('.')
          keys.each { |key|
            if key.include?('[')
              result.concat(parse_dot_array_op(key, param))
            else
              result << key
            end
          }

          raise Fluent::ConfigError, "empty keys in dot notation" if result.empty?
          validate_dot_keys(result)

          result
        end

        def self.validate_dot_keys(keys)
          keys.each { |key|
            next unless key.is_a?(String)
            if /\s+/.match?(key)
              raise Fluent::ConfigError, "whitespace character is not allowed in dot notation. Use bracket notation: #{key}"
            end
          }
        end

        def self.parse_dot_array_op(key, param)
          start = key.index('[')
          result = if start.zero?
                     []

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Fix the path to point at a real key: $.field or $.nested.field
  2. Validate that the path has a non-empty key portion before creating the accessor
  3. When keys come from external input, prefer bracket notation $['key'] which handles unusual key names

Example fix

# before
accessor = record_accessor_create(param) # param == '$.' -> empty keys in dot notation

# after
raise ArgumentError, 'record path must name a key' if param.length <= 2
accessor = record_accessor_create(param)
Defensive patterns

Strategy: validation

Validate before calling

# cheap pre-check for an empty key portion
raise ArgumentError, 'accessor path names no key' if param.length <= 2 || param == '$.[]'
accessor = record_accessor_create(param)

Try / catch

begin
  accessor = Fluent::RecordAccessor::Accessor.new(param)
rescue Fluent::ConfigError => e
  log.warn "bad record path #{param.inspect}: #{e.message}"
  accessor = nil
end

Prevention

When it happens

Trigger: record_accessor_create(param) or Fluent::RecordAccessor::Accessor.new(param) with param equal to '$.', '$..' or '$.[]' - typically the result of concatenating a nil/empty value into a path string.

Common situations: Building accessor paths dynamically from record fields, env vars or user input where the key part is empty; trailing-dot typos in config values that expect record_accessor parameters.

Related errors


AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21). Data as JSON: /api/errors/62d088611f125129. Report an issue: GitHub.