diff --git a/gateways/clients/hathor_core_client.py b/gateways/clients/hathor_core_client.py index 762ca56d..21f62c77 100644 --- a/gateways/clients/hathor_core_client.py +++ b/gateways/clients/hathor_core_client.py @@ -43,7 +43,11 @@ def __init__(self, url: Optional[str] = None) -> None: self.log = logger.new(client="async") async def get( - self, path: str, params: Optional[dict] = None, timeout: Optional[float] = None + self, + path: str, + params: Optional[dict] = None, + timeout: Optional[float] = None, + content_type: Optional[str] = "application/json", ) -> Dict[Any, Any]: """Make a get request async @@ -71,7 +75,7 @@ async def get( status=response.status, body=await response.text(), ) - return await response.json() + return await response.json(content_type=content_type) except Exception as e: self.log.error("hathor_core_error", path=path, error=repr(e)) return {"error": repr(e)} diff --git a/gateways/healthcheck_gateway.py b/gateways/healthcheck_gateway.py index 2d8703af..dcb983de 100644 --- a/gateways/healthcheck_gateway.py +++ b/gateways/healthcheck_gateway.py @@ -36,7 +36,12 @@ async def get_hathor_core_health(self) -> Optional[dict]: """Retrieve hathor-core health information""" return await self.hathor_core_async_client.get( - HEALTH_ENDPOINT, timeout=HEALTHCHECK_CLIENT_TIMEOUT_IN_SECONDS + # XXX: We set the expected content_type to None because hathor-core was returning 'text/html' instead of 'application/json' + # This will be fixed in the next release of hathor-core (v0.63.0) + # None is better here to avoid having to sync the releases of hathor-core and explorer-service + HEALTH_ENDPOINT, + timeout=HEALTHCHECK_CLIENT_TIMEOUT_IN_SECONDS, + content_type=None, ) def ping_redis(self) -> bool: diff --git a/tests/unit/gateways/test_healthcheck_gateway.py b/tests/unit/gateways/test_healthcheck_gateway.py index 3adb31f5..c6b587c3 100644 --- a/tests/unit/gateways/test_healthcheck_gateway.py +++ b/tests/unit/gateways/test_healthcheck_gateway.py @@ -26,7 +26,7 @@ async def mock_get_hathor_core_health(endpoint, **kwargs): result = await self.healthcheck_gateway.get_hathor_core_health() self.assertEqual(result, {"status": "pass"}) self.hathor_core_async_client.get.assert_called_once_with( - "/v1a/health", timeout=5 + "/v1a/health", timeout=5, content_type=None ) def test_ping_redis(self):