Skip to content

Improve error message when using '.' as a field name #70960

@fdartayre

Description

@fdartayre

Tested in 7.12.0

POST my_index/_doc
{".":{}}

returns:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "array_index_out_of_bounds_exception",
      "reason" : "Index -1 out of bounds for length 0"
    }
  },
  "status" : 400
}

The message is not clear, making it hard to identify the problem. It should be explicit as for empty field names:

POST my_index/_doc
{"":{}}
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "field name cannot be an empty string"
    }
  },
  "status" : 400
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions