Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions gateways/clients/hathor_core_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Comment thread
r4mmer marked this conversation as resolved.
except Exception as e:
self.log.error("hathor_core_error", path=path, error=repr(e))
return {"error": repr(e)}
Expand Down
7 changes: 6 additions & 1 deletion gateways/healthcheck_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/gateways/test_healthcheck_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down