fluent/fluentd · error · Fluent::ConfigError
'[' found but ']' not found. Invalid syntax: #{param}
Error message
'[' found but ']' not found. Invalid syntax: #{param} What it means
Fluent::ConfigError from Fluent::RecordAccessor's parse_dot_array_op. Once '[' is seen in dot notation, the parser scans for the matching ']'; if the remainder of the path ends before one is found, the path is syntactically incomplete and rejected with the full offending parameter in the message.
Source
Thrown at lib/fluent/plugin_helper/record_accessor.rb:147
start = key.index('[')
result = if start.zero?
[]
else
[key[0..start - 1]]
end
key = key[start + 1..-1]
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]View on GitHub (pinned to dd45c6e18d)
Solutions
- Close the bracket: $.array[1]
- When composing paths from fragments, assert each '[' has a matching ']'
- Prefer bracket notation $['key'][0] when generating paths programmatically - it is easier to build correctly
Example fix
# before
accessor = record_accessor_create('$.items[1')
# after
accessor = record_accessor_create('$.items[1]') Defensive patterns
Strategy: try-catch
Validate before calling
# assert brackets balance before creating the accessor
raise ArgumentError, 'unbalanced brackets' if param.count('[') != param.count(']')
accessor = record_accessor_create(param) Try / catch
begin
Fluent::RecordAccessor::Accessor.new(param)
rescue Fluent::ConfigError => e
log.error "malformed accessor #{param.inspect}: #{e.message}"
raise
end Prevention
- When templating paths, build segments in an array and join at the end
- Check bracket balance in generated paths during development
When it happens
Trigger: record_accessor_create with a dot-notation path having an unclosed bracket: $.array[1, $.a[0.b, or any path ending in '[' plus digits without ']'.
Common situations: Truncation of long paths by shell quoting or templating; hand-joining path fragments and dropping the closing bracket; regex-extracted keys that cut off at '['.
Related errors
- found more characters after ']'. Invalid syntax: #{param}
- empty keys in dot notation
- whitespace character is not allowed in dot notation. Use bra
- missing array index in '[]'. Invalid syntax: #{param}
- Incomplete bracket. Invalid syntax: #{orig_param}
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/dd13781d672664a6.
Report an issue: GitHub.