fluent/fluentd · error · Fluent::ConfigError

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

Error message

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

What it means

Fluent::ConfigError from Fluent::RecordAccessor's parse_bracket_notation. After a ']' closes a bracket, the only legal next character is '[' (another level) or end-of-string; any other trailing characters are rejected as garbage after the closing bracket.

Source

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

                  raise Fluent::ConfigError, "Incomplete bracket. Invalid syntax: #{orig_param}"
                end
              else
                if i = param.index(']')
                  index_value = param[0..i - 1]
                  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. Wrap the next segment in brackets: $[0]['foo']
  2. Quote string segments: $[0]['foo'] distinguishes keys from indexes
  3. Check the printed param in the message to see exactly which characters are extra

Example fix

# before
accessor = record_accessor_create("$[0]name")

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

Strategy: try-catch

Validate before calling

null

Try / catch

begin
  Fluent::RecordAccessor::Accessor.new(param)
rescue Fluent::ConfigError => e
  raise ArgumentError, "trailing characters in #{param.inspect}: #{e.message}"
end

Prevention

When it happens

Trigger: record_accessor_create with a bracket-notation path that has loose characters after a closed bracket: $[0]foo, $['a']bar].

Common situations: Concatenating path pieces and forgetting the next '['; intending $[0]['foo'] but writing $[0]foo.

Related errors


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