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

HTTP 500 response to invalid dynamic_mappings syntax #51486

Closed
jowiho opened this issue Jan 27, 2020 · 3 comments
Closed

HTTP 500 response to invalid dynamic_mappings syntax #51486

jowiho opened this issue Jan 27, 2020 · 3 comments
Labels
>bug help wanted adoptme :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@jowiho
Copy link
Contributor

jowiho commented Jan 27, 2020

Elasticsearch version: 7.5.2

Plugins installed: []

JVM version: (Elastic Cloud)

OS version: (Elastic Cloud)

Description of the problem including expected versus actual behavior:

Actual behavior: An (invalid) mappings update request, where dynamic_mappings is an object instead of an array, results in a http response with a 500 code.

Expected behavior: A 400 (bad request) http response code.

Steps to reproduce:

  1. Create a new index my_index
  2. Send the following request through Kibana's console
PUT /my_index/_mappings
{
  "dynamic_templates": {}
}
  1. Notice the 500 response:
{
  "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "class java.util.LinkedHashMap cannot be cast to class java.util.List (java.util.LinkedHashMap and java.util.List are in module java.base of loader 'bootstrap')"
      }
    ],
    "type": "class_cast_exception",
    "reason": "class java.util.LinkedHashMap cannot be cast to class java.util.List (java.util.LinkedHashMap and java.util.List are in module java.base of loader 'bootstrap')"
  },
  "status": 500
}
@cbuescher cbuescher added the :Search Foundations/Mapping Index mappings, including merging and defining field types label Jan 30, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@lmenezes
Copy link
Contributor

@elasticmachine care if I send a PR to fix this?

@jimczi jimczi added the >bug label Jan 30, 2020
@jimczi
Copy link
Contributor

jimczi commented Jan 30, 2020

Thanks @lmenezes, elasticmachine doesn't care ;) but I am sure our CI will be very happy to test your pr if you send one ;).

@jtibshirani jtibshirani added the help wanted adoptme label Jan 31, 2020
feifeiiiiiiiiiii added a commit to feifeiiiiiiiiiii/elasticsearch that referenced this issue Feb 1, 2020
cbuescher pushed a commit that referenced this issue Feb 4, 2020
Currently, a mappings update request, where dynamic_mappings is an object
instead of an array, results in a http response with a 500 code. This PR checks
for this condition and throws a MapperParsingException like we do for other
malformed mapping cases.

Closes #51486
@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug help wanted adoptme :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

7 participants