From 16ac5ae23cc1a7bcb3e7f19617e8a6233ec899b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Garbaci=C5=84ski?= <57113816+kgarbacinski@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:51:51 +0300 Subject: [PATCH] OCT-1843: Refetch when getting 404 error (#411) ## Description ## Definition of Done 1. [ ] Acceptance criteria are met. 2. [ ] PR is manually tested before the merge by developer(s). - [ ] Happy path is manually checked. 3. [ ] PR is manually tested by QA when their assistance is required (1). - [ ] Octant Areas & Test Cases are checked for impact and updated if required (2). 4. [ ] Unit tests are added unless there is a reason to omit them. 5. [ ] Automated tests are added when required. 6. [ ] The code is merged. 7. [ ] Tech documentation is added / updated, reviewed and approved (including mandatory approval by a code owner, should such exist for changed files). - [ ] BE: Swagger documentation is updated. 8. [ ] When required by QA: - [ ] Deployed to the relevant environment. - [ ] Passed system tests. --- (1) Developer(s) in coordination with QA decide whether it's required. For small tickets introducing small changes QA assistance is most probably not required. (2) [Octant Areas & Test Cases](https://docs.google.com/spreadsheets/d/1cRe6dxuKJV3a4ZskAwWEPvrFkQm6rEfyUCYwLTYw_Cc). --- backend/app/infrastructure/external_api/common.py | 3 ++- backend/app/modules/multisig_signatures/service/offchain.py | 3 ++- backend/app/modules/user/antisybil/service/initial.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/app/infrastructure/external_api/common.py b/backend/app/infrastructure/external_api/common.py index 462fd66e4..eaa545c7d 100644 --- a/backend/app/infrastructure/external_api/common.py +++ b/backend/app/infrastructure/external_api/common.py @@ -1,4 +1,5 @@ import time +from http import HTTPStatus from typing import Callable, Dict from app.exceptions import ExternalApiException @@ -6,7 +7,7 @@ def retry_request( req_func: Callable, - status_code: int, + status_code: HTTPStatus, no_retries: int = 3, sleep_time: int = 1, **kwargs, diff --git a/backend/app/modules/multisig_signatures/service/offchain.py b/backend/app/modules/multisig_signatures/service/offchain.py index 89bfbc1b3..f0716f7b0 100644 --- a/backend/app/modules/multisig_signatures/service/offchain.py +++ b/backend/app/modules/multisig_signatures/service/offchain.py @@ -1,3 +1,4 @@ +from http import HTTPStatus from typing import List, Dict from app.context.manager import Context @@ -101,7 +102,7 @@ def save_pending_signature( def _verify_owner(self, user_address: str, message_hash: str): message_details = retry_request( req_func=get_message_details, - status_code=404, + status_code=HTTPStatus.NOT_FOUND, message_hash=message_hash, is_mainnet=self.is_mainnet, ) diff --git a/backend/app/modules/user/antisybil/service/initial.py b/backend/app/modules/user/antisybil/service/initial.py index a9ed1f5a5..3314acd72 100644 --- a/backend/app/modules/user/antisybil/service/initial.py +++ b/backend/app/modules/user/antisybil/service/initial.py @@ -1,3 +1,5 @@ +from http import HTTPStatus + from flask import current_app as app from eth_utils.address import to_checksum_address @@ -52,7 +54,7 @@ def _retry_fetch(): raise ExternalApiException("GP: scoring is not completed yet", 503) if score["status"] != "DONE": - score = retry_request(_retry_fetch, 200) + score = retry_request(_retry_fetch, HTTPStatus.OK) all_stamps = fetch_stamps(user_address)["items"] cutoff = datetime.now()