From 9b340ba528ad3dd89a5733587e850713905acae0 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Mon, 23 Dec 2024 16:06:31 +0800 Subject: [PATCH 1/2] fix: improve error handling for file retrieval in AwsS3Storage Signed-off-by: -LAN- --- api/extensions/storage/aws_s3_storage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/extensions/storage/aws_s3_storage.py b/api/extensions/storage/aws_s3_storage.py index ab2d0fba3b19f3..748815eb9c1369 100644 --- a/api/extensions/storage/aws_s3_storage.py +++ b/api/extensions/storage/aws_s3_storage.py @@ -67,7 +67,9 @@ def load_stream(self, filename: str) -> Generator: yield from response["Body"].iter_chunks() except ClientError as ex: if ex.response["Error"]["Code"] == "NoSuchKey": - raise FileNotFoundError("File not found") + raise FileNotFoundError("file not found") + elif 'reached max retries' in str(ex): + raise ValueError("please do not request the same file too frequently") else: raise From 22ec8afa43f7b356f6f23eb5f3ec70ad2b4cba48 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Mon, 23 Dec 2024 16:11:36 +0800 Subject: [PATCH 2/2] chore: code format Signed-off-by: -LAN- --- api/extensions/storage/aws_s3_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/extensions/storage/aws_s3_storage.py b/api/extensions/storage/aws_s3_storage.py index 748815eb9c1369..ce36c2e7deeeda 100644 --- a/api/extensions/storage/aws_s3_storage.py +++ b/api/extensions/storage/aws_s3_storage.py @@ -68,7 +68,7 @@ def load_stream(self, filename: str) -> Generator: except ClientError as ex: if ex.response["Error"]["Code"] == "NoSuchKey": raise FileNotFoundError("file not found") - elif 'reached max retries' in str(ex): + elif "reached max retries" in str(ex): raise ValueError("please do not request the same file too frequently") else: raise