diff --git a/cycode/cyclient/scan_client.py b/cycode/cyclient/scan_client.py index 18f400ac..283438c2 100644 --- a/cycode/cyclient/scan_client.py +++ b/cycode/cyclient/scan_client.py @@ -5,6 +5,7 @@ import requests from requests import Response +from tenacity import retry, retry_if_exception, stop_after_attempt, wait_random_exponential from cycode.cli import consts from cycode.cli.config import configuration_manager @@ -166,6 +167,14 @@ def upload_to_presigned_post( raise SlowUploadConnectionError from e raise + # Ideally this retry would live in _execute (CycodeClientBase) so all callers benefit, + # but that requires making the retry predicate configurable per-call — a larger refactor. + @retry( + retry=retry_if_exception(lambda e: isinstance(e, RequestHttpError) and e.status_code == 404), + stop=stop_after_attempt(3), + wait=wait_random_exponential(multiplier=1, min=1, max=5), + reraise=True, + ) def scan_repository_from_upload_id( self, scan_type: str,