fluent/fluentd · error · Fluent::ConfigError

empty keys in bracket notation

Error message

empty keys in bracket notation

What it means

Fluent::ConfigError from Fluent::RecordAccessor's parse_bracket_notation. After the whole bracket expression is consumed, the accumulated key list must contain at least one entry; a path that opens a bracket and then ends, such as '$[', produces zero keys and is rejected as empty.

Source

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

                  raise Fluent::ConfigError, "missing array index in '[]'. Invalid syntax: #{param}" if index_value == ']'
                  result << Integer(index_value)
                  param = param[i + 1..-1]
                  in_bracket = false
                else
                  raise Fluent::ConfigError, "'[' found but ']' not found. Invalid syntax: #{orig_param}"
                end
              end
            else
              if i = param.index('[')
                param = param[i + 1..-1]
                in_bracket = true
              else
                raise Fluent::ConfigError, "found more characters after ']'. Invalid syntax: #{orig_param}"
              end
            end
          end

          raise Fluent::ConfigError, "empty keys in bracket notation" if result.empty?

          result
        end
      end
    end
  end
end

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Complete the path with a real key: $['key'] or $[0]
  2. Validate length: reject any param shorter than '$[x]' before creating the accessor
  3. Default missing dynamic keys to a safe concrete value instead of an empty template

Example fix

# before
accessor = record_accessor_create('$[')

# after
accessor = record_accessor_create("$['key']")
Defensive patterns

Strategy: validation

Validate before calling

raise ArgumentError, 'accessor path names no key' if param.length <= 2 || param == '$['
accessor = record_accessor_create(param)

Try / catch

begin
  Fluent::RecordAccessor::Accessor.new(param)
rescue Fluent::ConfigError => e
  log.warn "ignoring empty accessor path"
  nil
end

Prevention

When it happens

Trigger: record_accessor_create with a bracket-notation path of '$[' (or one whose every segment is empty), where the parser consumes '[' and the loop ends with an empty result list.

Common situations: Truncation of a path to its first two characters by templating or slicing; passing a '$'-prefixed path that was meant to be filled in later; defaulting a missing key to '$['.

Related errors


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