appbaseio / dejavu

The Missing Web UI for Elasticsearch: Import, browse and edit data with rich filters and query views, create search UIs visually.

Home Page:https://dejavu.reactivesearch.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Global search sends malformed request

knepp045 opened this issue · comments

commented

Issue
When connecting to an elastic backend (or doing a search from the data browser view) Deja Vu sends a POST request to https://<host>/<index>/_msearch?. Elastic has issues with the unnecessary ? in the url, sending back a 400 status code (bad request) with the following body:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"request [/test/_msearch] contains unrecognized parameter: [?]"}],"type":"illegal_argument_exception","reason":"request [/test/_msearch] contains unrecognized parameter: [?]"},"status":400}

If I replay the request (using curl) and edit out the ?, everything works fine.

Context/version
Using the lastest docker image v3.4.6 with Elastic 7.5.0 backend in Chrome 92.0.4515.159.

@knepp045 Can you share the actual network request that is sent by Dejavu? (You can remove any domain/authorization specific info from it) Knowing the URL and request body would help here.

commented

Sorry for not getting back to you sooner.

The full request (copied from Chrome as curl command) looks like this:

curl 'https://proxy-search.apps.ml01.<domain>.<tld>/test/_msearch?' \
  -H 'Connection: keep-alive' \
  -H 'sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"' \
  -H 'accept: application/json' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36' \
  -H 'content-type: application/x-ndjson' \
  -H 'Origin: https://proxy-search.apps.ml01.<domain>.<tld>' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Referer: https://proxy-search.apps.ml01.<domain>.<tld>/?appname=test&url=https://proxy-search.apps.ml01.<domain>.<tld>&mode=edit' \
  -H 'Accept-Language: nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7' \
  -H 'Cookie: toestemmingvoorcookies=ja; _pk_id.97.17a0=<string>; _pk_id.34.17a0=<string>; CID=<string>; ABTasty=uid=<string>&cst=<string>; _gcl_au=<string>; _ga=<string>; _fbp=<string>; _ga_JWWFBERW5V=<string>; _oauth_proxy=<string>' \
  --data-raw $'{"preference":"results"}\n{"query":{"match_all":{}},"size":15,"_source":{"includes":["*"],"excludes":[]},"from":0,"sort":[{"_score":{"order":"desc"},"_id":{"order":"desc"}}],"track_total_hits":true}\n' \
  --compressed

The cookies in the header are set by oauthproxy. Both Dejavu and the Elastic backend are behind a proxy that takes care of authentication.

The problem may of course be caused by this proxy, although it does not rewrite the url or change the request in any way. Also, if I remove the ? after _msearch, Elastic returns the expected results.

Thanks @knepp045, we're able to replicate this issue.

This is released with v3.5.1.