opensearch-project/OpenSearch

[BUG] Server errors propagated with index creation requests

Open

#7,096 opened on Apr 11, 2023

View on GitHub
 (4 comments) (1 reaction) (1 assignee)Java (1,505 forks)batch import
Indexingbuggood first issue

Repository metrics

Stars
 (8,123 stars)
PR merge metrics
 (Avg merge 5d 9h) (266 merged PRs in 30d)

Description

Describe the bug

Server errors within OpenSearch are exposed to the client when trying to create an index under certain conditions.


Condition 1: When the request body is numeric

PUT /testindex7?pretty HTTP/1.1
Host: ...
User-Agent: curl/7.86.0
Authorization: Basic [...]
Content-Type: application/json
Accept: application/xml
Connection: close
Content-Length: 1

0

Response:

HTTP/1.1 500 Internal Server Error
content-type: application/json; charset=UTF-8
content-length: 390

{
  "error" : {
    "root_cause" : [
      {
        "type" : "not_x_content_exception",
        "reason" : "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
      }
    ],
    "type" : "not_x_content_exception",
    "reason" : "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
  },
  "status" : 500
}

Condition 2: When cluster manager is unavailable Response:

HTTP/1.1 503 Service Unavailable
content-type: application/json; charset=UTF-8
content-length: 246

{
  "error" : {
    "root_cause" : [
      {
        "type" : "cluster_manager_not_discovered_exception",
        "reason" : null
      }
    ],
    "type" : "cluster_manager_not_discovered_exception",
    "reason" : null
  },
  "status" : 503
}

To Reproduce Steps to reproduce the behavior:

  1. Create an index with the above conditions

Expected behavior

  • The response should abstract out the underlying reason for failure by sending a 400 (Bad Request) response back to the client
  • This behavior can be made configurable where setting a property on the server disables or enables the stack trace and detailed response

Host/Environment (please complete the following information):

  • OS: AL2

Additional context

  • N/A

Contributor guide