From 52171b1b100e80f5efe4dd09bcbd18c3245a1fea Mon Sep 17 00:00:00 2001 From: Jah-yee <166608075+Jah-yee@users.noreply.github.com> Date: Sat, 3 Oct 2026 15:50:42 +0800 Subject: [PATCH] Fix S3 block size error messages to match their checks - s3.py: Fix message to say 'at least 5 MiB (5242880 bytes)' instead of incorrectly showing byte count with MB suffix - s3.py & s3_async.py: Fix 'greater than' to 'at least' and 'less than' to 'at most' since the checks use inclusive bounds [<, >] Fixes #926. --- pyathena/filesystem/s3.py | 4 ++-- pyathena/filesystem/s3_async.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyathena/filesystem/s3.py b/pyathena/filesystem/s3.py index 3d039832c..58ac57a02 100644 --- a/pyathena/filesystem/s3.py +++ b/pyathena/filesystem/s3.py @@ -1275,7 +1275,7 @@ def _copy_object_with_multipart_upload( block_size < self.MULTIPART_UPLOAD_MIN_PART_SIZE or block_size > self.MULTIPART_UPLOAD_MAX_PART_SIZE ): - raise ValueError("Block size must be greater than 5MiB and less than 5GiB.") + raise ValueError("Block size must be at least 5 MiB (5242880 bytes) and at most 5 GiB (5368709120 bytes).") copy_source = { "Bucket": bucket1, @@ -2322,7 +2322,7 @@ def __init__( if "r" not in mode and block_size < self.fs.MULTIPART_UPLOAD_MIN_PART_SIZE: # When writing occurs, the block size should not be smaller # than the minimum size of a part in a multipart upload. - raise ValueError(f"Block size must be >= {self.fs.MULTIPART_UPLOAD_MIN_PART_SIZE}MB.") + raise ValueError(f"Block size must be >= 5 MiB ({self.fs.MULTIPART_UPLOAD_MIN_PART_SIZE} bytes).") self.append_block = False if "a" in mode and self.fs.exists(path): diff --git a/pyathena/filesystem/s3_async.py b/pyathena/filesystem/s3_async.py index 77deccc2a..eb1f624c9 100644 --- a/pyathena/filesystem/s3_async.py +++ b/pyathena/filesystem/s3_async.py @@ -281,7 +281,7 @@ async def _copy_object_with_multipart_upload( block_size < S3FileSystem.MULTIPART_UPLOAD_MIN_PART_SIZE or block_size > S3FileSystem.MULTIPART_UPLOAD_MAX_PART_SIZE ): - raise ValueError("Block size must be greater than 5MiB and less than 5GiB.") + raise ValueError("Block size must be at least 5 MiB (5242880 bytes) and at most 5 GiB (5368709120 bytes).") copy_source: dict[str, Any] = { "Bucket": bucket1,