Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "." as field name yields array_index_out_of_bounds_exception #14911

Closed
shdubsh opened this issue Jul 23, 2024 · 1 comment · Fixed by #15126
Closed

[BUG] "." as field name yields array_index_out_of_bounds_exception #14911

shdubsh opened this issue Jul 23, 2024 · 1 comment · Fixed by #15126
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing v2.17.0 v3.0.0 Issues and PRs related to version 3.0.0

Comments

@shdubsh
Copy link
Contributor

shdubsh commented Jul 23, 2024

Describe the bug

"." as field name yields array_index_out_of_bounds_exception

Related component

Indexing

To Reproduce

Dev Tools:

POST index_name/_doc
{".":"foo"}

Yields

{
  "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
}

Expected behavior

We could either index the document or yield a better error message.

Additional Details

Plugins
Defaults in docker

Screenshots
n/a

Host/Environment (please complete the following information):

  • OS: n/a - using docker.io/opensearchproject/opensearch:latest
  • Version - affects 2.15.0 and earlier

Additional context
n/a

@shdubsh shdubsh added bug Something isn't working untriaged labels Jul 23, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Jul 23, 2024
@gaobinlong
Copy link
Collaborator

The exception is thrown here because subfields is empty in this case:

return objectMapper.getMapper(subfields[subfields.length - 1]);
, since . is reserved for object resolution, we can fail the indexing request when . is used as a field name, @shdubsh mind opening a PR for this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing v2.17.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
3 participants