fluent/fluentd · error · Fluent::ConfigError

found more characters after ']'. Invalid syntax: #{param}

Error message

found more characters after ']'. Invalid syntax: #{param}

What it means

Fluent::ConfigError from Fluent::RecordAccessor's parse_dot_array_op. After a closed array index in dot notation, the next character must be '[' (a further index) or nothing; trailing characters that are neither a new bracket nor empty mean garbage after ']' and the path is rejected.

Source

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

          in_bracket = true

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

          result
        end

        def self.parse_bracket_notation(param)
          orig_param = param
          result = []
          param = param[1..-1]
          in_bracket = false

          until param.empty?
            if in_bracket
              if param[0] == "'" || param[0] == '"'
                if i = param.index("']") || param.index('"]')
                  raise Fluent::ConfigError, "Mismatched quotes. Invalid syntax: #{orig_param}" unless param[0] == param[i]

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Separate the next field with a dot: $.arr[0].bar
  2. Chain further indexes as brackets: $.arr[0][1]
  3. Re-read the message's printed param to find exactly where the extra characters start

Example fix

# before
accessor = record_accessor_create('$.items[0]name')

# after
accessor = record_accessor_create('$.items[0].name')
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

begin
  accessor = Fluent::RecordAccessor::Accessor.new(param)
rescue Fluent::ConfigError => e
  # e.message contains the exact param; surface it to the config author
  raise ConfigValidationError, "fix path #{param.inspect}: #{e.message}"
end

Prevention

When it happens

Trigger: record_accessor_create with a dot-notation path that continues with bare characters after an index bracket: $.arr[0]bar, $.list[1]x[2] without dots/brackets in valid positions.

Common situations: Concatenating an index onto a key path and then appending a field name without a dot: intending $.arr[0].bar but writing $.arr[0]bar.

Related errors


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