diff --git a/awscrt/s3.py b/awscrt/s3.py index 9a0aab525..816a718ae 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-cal b/crt/aws-c-cal index 96c47e339..71810b1ad 160000 --- a/crt/aws-c-cal +++ b/crt/aws-c-cal @@ -1 +1 @@ -Subproject commit 96c47e339d030d1fa4eaca201be948bc4442510d +Subproject commit 71810b1ade7af4747104ae245b74240ae8e8cf77 diff --git a/crt/aws-c-common b/crt/aws-c-common index 4f874cea5..6d974f92c 160000 --- a/crt/aws-c-common +++ b/crt/aws-c-common @@ -1 +1 @@ -Subproject commit 4f874cea50a70bc6ebcd85c6ce1c6c0016b5aff4 +Subproject commit 6d974f92c1d86391c1dcb1173239adf757c52b2d diff --git a/crt/aws-c-s3 b/crt/aws-c-s3 index 6588f9a71..cb431ba06 160000 --- a/crt/aws-c-s3 +++ b/crt/aws-c-s3 @@ -1 +1 @@ -Subproject commit 6588f9a714ee7a8be1bddd63ea5ea1ea224d00b4 +Subproject commit cb431ba06b5d3db4373cd8fb55d6c16464cbf2ea diff --git a/crt/aws-lc b/crt/aws-lc index 4e54dd836..05d3bfd63 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 114ccab0f..073c7b415 160000 --- a/crt/s2n +++ b/crt/s2n @@ -1 +1 @@ -Subproject commit 114ccab0ff2cde491203ac841837d0d39b767412 +Subproject commit 073c7b415a17d271a7b2c8c385d0e641fc94871f