fluent/fluentd · error · Fluent::ConfigError

Mismatched quotes. Invalid syntax: #{orig_param}

Error message

Mismatched quotes. Invalid syntax: #{orig_param}

What it means

Fluent::ConfigError from Fluent::RecordAccessor's parse_bracket_notation. When a bracket-notation key is quoted, the opening quote character must match the character right before the closing ']' - '$['...'" ... must end with '] and "$["..."]" must end with "]. Mixing quote styles fails the param[0] == param[i] check and raises with the original path.

Source

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

                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]
                  result << param[1..i - 1]
                  param = param[i + 2..-1]
                  in_bracket = false
                else
                  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

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Use matching quotes on both sides: $['key'] or $["key"]
  2. When generating paths in code, emit the closer from the same variable as the opener
  3. Skip quotes entirely for simple identifier keys: $.key or $[key]

Example fix

# before
accessor = record_accessor_create('$[\'key"]')

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

Strategy: try-catch

Validate before calling

# verify quote pairing before use
ok = param.match?(%r{\A\$\[(['"]).*\1\]\z})
raise ArgumentError, 'quotes in accessor path do not match' unless ok
accessor = record_accessor_create(param)

Try / catch

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

Prevention

When it happens

Trigger: record_accessor_create with a mismatched-quoted bracket key: $['key"] or $["key'] - the opener and the quote preceding ']' differ.

Common situations: Building paths by string interpolation where the closing sequence is hardcoded as "']" regardless of the opener; converting between single- and double-quoted styles by hand and editing only one side.

Related errors


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