Skip to content

Commit 5e4f6fa

Browse files
olethanhnesitor
authored andcommitted
Handle edge case if server response is invalid
1 parent 37e70c5 commit 5e4f6fa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/aleph/vm/orchestrator/payment.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ async def get_address_balance(address: str) -> dict:
4040

4141
# Raise an error if the request failed
4242
resp.raise_for_status()
43+
ret = await resp.json()
44+
if not isinstance(ret, dict):
45+
msg = f"get_address_blaance: Invalid response received from {url}, should be dict"
46+
raise Exception(msg)
4347

44-
return await resp.json()
48+
return ret
4549

4650

4751
async def fetch_balance_of_address(address: str) -> Decimal:

0 commit comments

Comments
 (0)