From 0660d0dcedee861209ad428a9deb10b8e0c56109 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Fri, 21 Jun 2024 08:51:23 -0700 Subject: [PATCH 1/4] S3Client breaking change: DEFAULT requests must pass operation name --- awscrt/s3.py | 27 ++++++++++++++++++++++----- crt/aws-c-s3 | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/awscrt/s3.py b/awscrt/s3.py index 9a0aab52..816a718a 100644 --- a/awscrt/s3.py +++ b/awscrt/s3.py @@ -314,10 +314,25 @@ def make_request( request (HttpRequest): The overall outgoing API request for S3 operation. If the request body is a file, set send_filepath for better performance. - operation_name(Optional[str]): Optional S3 operation name (e.g. "CreateBucket"). - This will only be used when `type` is :attr:`~S3RequestType.DEFAULT`; - it is automatically populated for other types. + operation_name(Optional[str]): S3 operation name (e.g. "CreateBucket"). + This MUST be set when `type` is :attr:`~S3RequestType.DEFAULT`. + It is ignored for other types, since the operation is implicitly known. + See `S3 API documentation + `_ + for the canonical list of names. + This name is used to fill out details in metrics and error reports. + It also drives some operation-specific behavior. + If you pass the wrong name, you risk getting the wrong behavior. + + For example, every operation except "GetObject" has its response checked + for error, even if the HTTP status-code was 200 OK + (see `knowledge center `_). + If you used the :attr:`~S3RequestType.DEFAULT` type to do + `GetObject `_, + but mis-named it "Download", and the object looked like XML with an error code, + then the request would fail. You risk logging the full response body, + and leaking sensitive data. recv_filepath (Optional[str]): Optional file path. If set, the response body is written directly to a file and the @@ -499,6 +514,9 @@ def __init__( assert isinstance(part_size, int) or part_size is None assert isinstance(multipart_upload_threshold, int) or multipart_upload_threshold is None + if type == S3RequestType.DEFAULT and not operation_name: + raise ValueError("'operation_name' must be set when using S3RequestType.DEFAULT") + super().__init__() self._finished_future = Future() @@ -567,12 +585,11 @@ class S3ResponseError(awscrt.exceptions.AwsCrtError): headers (list[tuple[str, str]]): Headers from HTTP response. body (Optional[bytes]): Body of HTTP response (if any). This is usually XML. It may be None in the case of a HEAD response. - operation_name (Optional[str]): Name of the S3 operation that failed (if known). + operation_name: Name of the S3 operation that failed. For example, if a :attr:`~S3RequestType.PUT_OBJECT` fails this could be "PutObject", "CreateMultipartUpload", "UploadPart", "CompleteMultipartUpload", or others. For :attr:`~S3RequestType.DEFAULT`, this is the `operation_name` passed to :meth:`S3Client.make_request()`. - If the S3 operation name is unknown, this will be None. code (int): CRT error code. name (str): CRT error name. message (str): CRT error message. diff --git a/crt/aws-c-s3 b/crt/aws-c-s3 index 6588f9a7..a549581c 160000 --- a/crt/aws-c-s3 +++ b/crt/aws-c-s3 @@ -1 +1 @@ -Subproject commit 6588f9a714ee7a8be1bddd63ea5ea1ea224d00b4 +Subproject commit a549581ca98c49ad29a00c58246386c585046f9a From d03cbce614a34d2672cb5a876aec2d328d2487be Mon Sep 17 00:00:00 2001 From: Dengke Tang Date: Fri, 28 Jun 2024 12:01:06 -0700 Subject: [PATCH 2/4] point to the tag --- crt/aws-c-s3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crt/aws-c-s3 b/crt/aws-c-s3 index a549581c..cb431ba0 160000 --- a/crt/aws-c-s3 +++ b/crt/aws-c-s3 @@ -1 +1 @@ -Subproject commit a549581ca98c49ad29a00c58246386c585046f9a +Subproject commit cb431ba06b5d3db4373cd8fb55d6c16464cbf2ea From b4a2d4b230afe092f7e9abcfa5af7cbb15c2f99f Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Tue, 2 Jul 2024 16:36:22 -0700 Subject: [PATCH 3/4] latest submodules: aws-c-cal v0.6.15 -> v0.7.0 aws-c-common v0.9.21 -> v0.9.23 aws-c-s3 v0.5.10 -> v0.6.0 aws-lc v1.29.0 -> v1.31.0 s2n v1.4.16 -> v1.4.17 --- crt/aws-c-cal | 2 +- crt/aws-c-common | 2 +- crt/aws-lc | 2 +- crt/s2n | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crt/aws-c-cal b/crt/aws-c-cal index 96c47e33..11fc6844 160000 --- a/crt/aws-c-cal +++ b/crt/aws-c-cal @@ -1 +1 @@ -Subproject commit 96c47e339d030d1fa4eaca201be948bc4442510d +Subproject commit 11fc68445b2b4993656ed720fc2788f3c4c7c20f diff --git a/crt/aws-c-common b/crt/aws-c-common index 4f874cea..6d974f92 160000 --- a/crt/aws-c-common +++ b/crt/aws-c-common @@ -1 +1 @@ -Subproject commit 4f874cea50a70bc6ebcd85c6ce1c6c0016b5aff4 +Subproject commit 6d974f92c1d86391c1dcb1173239adf757c52b2d diff --git a/crt/aws-lc b/crt/aws-lc index 4e54dd83..05d3bfd6 160000 --- a/crt/aws-lc +++ b/crt/aws-lc @@ -1 +1 @@ -Subproject commit 4e54dd8363396f257d7a2317c48101e18170e6fb +Subproject commit 05d3bfd6303c65d7392dee1a47d6e161c36a04e5 diff --git a/crt/s2n b/crt/s2n index 114ccab0..073c7b41 160000 --- a/crt/s2n +++ b/crt/s2n @@ -1 +1 @@ -Subproject commit 114ccab0ff2cde491203ac841837d0d39b767412 +Subproject commit 073c7b415a17d271a7b2c8c385d0e641fc94871f From a0df98fa9c1b2db7c2a36225eccd45078acedbfa Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Wed, 3 Jul 2024 13:58:43 -0700 Subject: [PATCH 4/4] aws-c-cal v0.7.0 -> v0.7.1 --- crt/aws-c-cal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crt/aws-c-cal b/crt/aws-c-cal index 11fc6844..71810b1a 160000 --- a/crt/aws-c-cal +++ b/crt/aws-c-cal @@ -1 +1 @@ -Subproject commit 11fc68445b2b4993656ed720fc2788f3c4c7c20f +Subproject commit 71810b1ade7af4747104ae245b74240ae8e8cf77