From 303d402d654b370d6104d7b864062103fc6ea053 Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria <6909403+Uxio0@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:15:23 +0100 Subject: [PATCH] Fix `update_token_info_from_token_list_task` - Address was not checked and could be `None`. - If `chainId` is not specified, we assume it's matching the current one. - Exclude tokens without `address` --- safe_transaction_service/tokens/tasks.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/safe_transaction_service/tokens/tasks.py b/safe_transaction_service/tokens/tasks.py index 6cfa41a0a..e2d7a9933 100644 --- a/safe_transaction_service/tokens/tasks.py +++ b/safe_transaction_service/tokens/tasks.py @@ -111,7 +111,14 @@ def update_token_info_from_token_list_task() -> int: Token.objects.update(trusted=False) for token in filtered_tokens: if token_address := _parse_token_address_from_token_list(token["address"]): + logo_uri = token.get("logoURI") or "" + if len(logo_uri) > 200: + # URLField has a limit of 200 chars + logger.error( + "Logo uri for token %s is exceeding 200 chars", token_address + ) + logo_uri = "" tokens_updated_count += Token.objects.filter( address=token_address - ).update(logo_uri=token.get("logoURI") or "", trusted=True) + ).update(logo_uri=logo_uri, trusted=True) return tokens_updated_count