Repository: deepset-ai/haystack

Issue:
Connection Error. Is Haystack running? JSON Issue with Docker Compose On Fresh Repo and Image Pulls
### Discussed in https://github.com/deepset-ai/haystack/discussions/1617

<div type='discussions-op-text'>

<sup>Originally posted by **sieu-tran** October 19, 2021</sup>
Between October 18, 2021 and October 19, 2021, something has changed and the docker returns the error: "Connection Error. Is Haystack running?" when we start running it.</div>


Discussion:
Terminal output when running docker-compose up from clean repo download and image pulls:

haystack-api_1   | ML Logging is turned off. No parameters, metrics or artifacts will be logged to MLFlow.
haystack-api_1   | [2021-10-19 19:16:54 +0000] [10] [INFO] Started server process [10]
haystack-api_1   | [2021-10-19 19:16:54 +0000] [10] [INFO] Waiting for application startup.
haystack-api_1   | [2021-10-19 19:16:54 +0000] [10] [INFO] Application startup complete.
haystack-api_1   | [2021-10-19 19:16:54 +0000] [10] [ERROR] Exception in ASGI application
haystack-api_1   | Traceback (most recent call last):
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 375, in run_asgi
haystack-api_1   |     result = await app(self.scope, self.receive, self.send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
haystack-api_1   |     return await self.app(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 208, in __call__
haystack-api_1   |     await super().__call__(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 112, in __call__
haystack-api_1   |     await self.middleware_stack(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in __call__
haystack-api_1   |     raise exc
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in __call__
haystack-api_1   |     await self.app(scope, receive, _send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/cors.py", line 84, in __call__
haystack-api_1   |     await self.app(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 82, in __call__
haystack-api_1   |     raise exc
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 71, in __call__
haystack-api_1   |     await self.app(scope, receive, sender)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 656, in __call__
haystack-api_1   |     await route.handle(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 259, in handle
haystack-api_1   |     await self.app(scope, receive, send)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 61, in app
haystack-api_1   |     response = await func(request)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 227, in app
haystack-api_1   |     dependant=dependant, values=values, is_coroutine=is_coroutine
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
haystack-api_1   |     return await run_in_threadpool(dependant.call, **values)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
haystack-api_1   |     return await anyio.to_thread.run_sync(func, *args)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/anyio/to_thread.py", line 29, in run_sync
haystack-api_1   |     limiter=limiter)
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 805, in run_sync_in_worker_thread
haystack-api_1   |     return await future
haystack-api_1   |   File "/usr/local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 743, in run
haystack-api_1   |     result = func(*args)
haystack-api_1   |   File "/home/user/rest_api/controller/search.py", line 48, in query
haystack-api_1   |     result = _process_request(PIPELINE, request)
haystack-api_1   |   File "/home/user/rest_api/controller/search.py", line 66, in _process_request
haystack-api_1   |     result = pipeline.run(query=request.query, params=params)
haystack-api_1   |   File "/home/user/haystack/pipeline.py", line 300, in run
haystack-api_1   |     raise ValueError(f"No node(s) or global parameter(s) named {', '.join(invalid_keys)} found in pipeline.")
haystack-api_1   | ValueError: No node(s) or global parameter(s) named ESRetriever found in pipeline.
ui_1             | 2021-10-19 19:16:54.134 Expecting value: line 1 column 1 (char 0)
ui_1             | Traceback (most recent call last):
ui_1             |   File "/home/user/webapp.py", line 134, in main
ui_1             |     results, raw_json = retrieve_doc(question, top_k_reader=top_k_reader, top_k_retriever=top_k_retriever)
ui_1             |   File "/usr/local/lib/python3.7/site-packages/streamlit/caching.py", line 545, in wrapped_func
ui_1             |     return get_or_create_cached_value()
ui_1             |   File "/usr/local/lib/python3.7/site-packages/streamlit/caching.py", line 527, in get_or_create_cached_value
ui_1             |     return_value = func(*args, **kwargs)
ui_1             |   File "/home/user/utils.py", line 30, in retrieve_doc
ui_1             |     response_raw = requests.post(url, json=req).json()
ui_1             |   File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 910, in json
ui_1             |     return complexjson.loads(self.text, **kwargs)
ui_1             |   File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
ui_1             |     return _default_decoder.decode(s)
ui_1             |   File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
ui_1             |     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
ui_1             |   File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
ui_1             |     raise JSONDecodeError("Expecting value", s, err.value) from None
ui_1             | json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Resolving patch:
diff --git a/ui/utils.py b/ui/utils.py
--- a/ui/utils.py
+++ b/ui/utils.py
@@ -25,7 +25,7 @@ def haystack_is_ready():
 def retrieve_doc(query, filters=None, top_k_reader=5, top_k_retriever=5):
     # Query Haystack API
     url = f"{API_ENDPOINT}/{DOC_REQUEST}"
-    params = {"filters": filters, "ESRetriever": {"top_k": top_k_retriever}, "Reader": {"top_k": top_k_reader}}
+    params = {"filters": filters, "Retriever": {"top_k": top_k_retriever}, "Reader": {"top_k": top_k_reader}}
     req = {"query": query, "params": params}
     response_raw = requests.post(url, json=req).json()
 


Test patch: