{"record":{"id":"8672b484d0c44414","repo":"fluent/fluentd","slug":"empty-keys-in-bracket-notation","errorCode":null,"errorMessage":"empty keys in bracket notation","messagePattern":"empty keys in bracket notation","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin_helper/record_accessor.rb","lineNumber":200,"sourceCode":"                  raise Fluent::ConfigError, \"missing array index in '[]'. Invalid syntax: #{param}\" if index_value == ']'\n                  result << Integer(index_value)\n                  param = param[i + 1..-1]\n                  in_bracket = false\n                else\n                  raise Fluent::ConfigError, \"'[' found but ']' not found. Invalid syntax: #{orig_param}\"\n                end\n              end\n            else\n              if i = param.index('[')\n                param = param[i + 1..-1]\n                in_bracket = true\n              else\n                raise Fluent::ConfigError, \"found more characters after ']'. Invalid syntax: #{orig_param}\"\n              end\n            end\n          end\n\n          raise Fluent::ConfigError, \"empty keys in bracket notation\" if result.empty?\n\n          result\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":182,"sourceCodeEnd":208,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin_helper/record_accessor.rb#L182-L208","documentation":"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.","triggerScenarios":"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.","commonSituations":"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 '$['.","solutions":["Complete the path with a real key: $['key'] or $[0]","Validate length: reject any param shorter than '$[x]' before creating the accessor","Default missing dynamic keys to a safe concrete value instead of an empty template"],"exampleFix":"# before\naccessor = record_accessor_create('$[')\n\n# after\naccessor = record_accessor_create(\"$['key']\")","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'accessor path names no key' if param.length <= 2 || param == '$['\naccessor = record_accessor_create(param)","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::RecordAccessor::Accessor.new(param)\nrescue Fluent::ConfigError => e\n  log.warn \"ignoring empty accessor path\"\n  nil\nend","preventionTips":["Default dynamic keys to a concrete value, never to an empty template","Assert param.length >= 4 ('$[x]'.length) before creating accessors from templates"],"tags":["fluentd","record-accessor","bracket-notation","syntax"],"backgroundTag":"invalid-path-expression","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}