Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-24763

ES passthrough should return the correct ES HTTP status when an error occurs

    XMLWordPrintable

    Details

      Description

      Using the analytics dashboard, when the query fails, the returned http status from the passthrough is always 200 even though the underlying request to ES was actually 400. Therefore the UI doesn't display any popup about an error in ES

      Here is the curl request with unexpected date format that should return a 400:

      curl -vvv 'http://localhost:8080/nuxeo/site/es/_all/_search' -H 'properties: *' --data-binary '{"query":{"bool":{"must":[{"range":{"dc:created":{"gte":"2018-03-03T08:00:00.000Z","lte":"2018-04-03T07:00:00.000Z"}}}]}},"aggs":{"by":{"date_histogram":{"field":"dc:created","interval":"week","format":"yyyy-MM-dd","min_doc_count":0,"extended_bounds":{"min":"2018-03-03T08:00:00.000Z","max":"2018-04-03T07:00:00.000Z"}}}}}'
      

      Response header:

      HTTP/1.1 200
      < Date: Tue, 03 Apr 2018 20:35:18 GMT
      < Content-Type: application/json
      < Transfer-Encoding: chunked
      < Connection: keep-alive
      < Server: Apache/2.4.18 (Ubuntu)
      < X-Frame-Options: SAMEORIGIN
      < X-Frame-Options: SAMEORIGIN
      < X-UA-Compatible: IE=10; IE=11
      < Cache-Control: no-cache, no-store, must-revalidate
      < X-Content-Type-Options: nosniff
      < Content-Security-Policy: img-src data: blob: *; default-src blob: *; script-src 'unsafe-inline' 'unsafe-eval' data: *; style-src 'unsafe-inline' *; font-src data: *
      < X-XSS-Protection: 1; mode=block
      < Access-Control-Allow-Credentials: true
      < Vary: Origin
      < Access-Control-Expose-Headers: Accept-Ranges, Content-Range, Content-Encoding, Content-Length
      

      and here is the response payload:

      {
        "error": {
          "root_cause": [
            {
              "type": "parse_exception",
              "reason": "failed to parse date field [2018-03-03T08:00:00.000Z] with format [yyyy-MM-dd]"
            }
          ],
          "type": "search_phase_execution_exception",
          "reason": "all shards failed",
          "phase": "query",
          "grouped": true,
          "failed_shards": [
            {
              "shard": 0,
              "index": "nuxeo",
              "node": "dio9UUwqTzqfPJ_NmSsFGQ",
              "reason": {
                "type": "parse_exception",
                "reason": "failed to parse date field [2018-03-03T08:00:00.000Z] with format [yyyy-MM-dd]",
                "caused_by": {
                  "type": "illegal_argument_exception",
                  "reason": "Unrecognized chars at the end of [2018-03-03T08:00:00.000Z]: [T08:00:00.000Z]"
                }
              }
            }
          ]
        },
        "status": 400
      }
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: