Skip to content

Commit

Permalink
S3Client breaking change: DEFAULT requests must pass operation_name (#…
Browse files Browse the repository at this point in the history
…574)

**Issue:**
see: awslabs/aws-c-s3#439

**Description of changes:**

- `S3Client.make_request()` now requires `operation_name` to be set when `type` is `S3RequestType.DEFAULT`. (see [S3 API](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Operations_Amazon_Simple_Storage_Service.html) for canonical list of names)
- latest submodules:
    ```
    aws-c-cal          v0.6.15 -> v0.7.1
    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
    ```
  • Loading branch information
graebm committed Jul 3, 2024
1 parent 00a410f commit 1424d91
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
27 changes: 22 additions & 5 deletions awscrt/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://docs.aws.amazon.com/AmazonS3/latest/API/API_Operations_Amazon_Simple_Storage_Service.html>`_
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 <https://repost.aws/knowledge-center/s3-resolve-200-internalerror>`_).
If you used the :attr:`~S3RequestType.DEFAULT` type to do
`GetObject <https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html>`_,
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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-common
Submodule aws-c-common updated 83 files
+1 −1 .clang-tidy
+4 −7 .github/workflows/clang-format.yml
+6 −5 .github/workflows/proof_ci_resources/config.yaml
+10 −1 CMakeLists.txt
+26 −0 THIRD-PARTY-LICENSES.txt
+47 −0 format-check.py
+0 −24 format-check.sh
+2 −4 include/aws/common/atomics.h
+1 −1 include/aws/common/byte_buf.h
+449 −0 include/aws/common/cbor.h
+2 −4 include/aws/common/condition_variable.h
+7 −2 include/aws/common/error.h
+3 −2 include/aws/common/logging.h
+19 −1 include/aws/common/macros.h
+2 −4 include/aws/common/mutex.h
+19 −0 include/aws/common/private/byte_buf.h
+7 −3 include/aws/common/private/external_module_impl.h
+2 −4 include/aws/common/rw_lock.h
+1 −1 include/aws/common/statistics.h
+1 −2 include/aws/common/thread.h
+129 −0 scripts/import_libcbor.py
+8 −3 scripts/latest_submodules.py
+1 −1 source/allocator.c
+3 −1 source/android/logging.c
+19 −0 source/byte_buf.c
+647 −0 source/cbor.c
+12 −2 source/common.c
+19 −0 source/external/libcbor/allocators.c
+425 −0 source/external/libcbor/cbor.c
+74 −0 source/external/libcbor/cbor.h
+131 −0 source/external/libcbor/cbor/arrays.c
+137 −0 source/external/libcbor/cbor/arrays.h
+119 −0 source/external/libcbor/cbor/bytestrings.c
+150 −0 source/external/libcbor/cbor/bytestrings.h
+121 −0 source/external/libcbor/cbor/callbacks.c
+189 −0 source/external/libcbor/cbor/callbacks.h
+14 −0 source/external/libcbor/cbor/cbor_export.h
+163 −0 source/external/libcbor/cbor/common.c
+339 −0 source/external/libcbor/cbor/common.h
+46 −0 source/external/libcbor/cbor/configuration.h
+264 −0 source/external/libcbor/cbor/data.h
+200 −0 source/external/libcbor/cbor/encoding.c
+140 −0 source/external/libcbor/cbor/encoding.h
+189 −0 source/external/libcbor/cbor/floats_ctrls.c
+240 −0 source/external/libcbor/cbor/floats_ctrls.h
+422 −0 source/external/libcbor/cbor/internal/builder_callbacks.c
+85 −0 source/external/libcbor/cbor/internal/builder_callbacks.h
+98 −0 source/external/libcbor/cbor/internal/encoders.c
+41 −0 source/external/libcbor/cbor/internal/encoders.h
+80 −0 source/external/libcbor/cbor/internal/loaders.c
+43 −0 source/external/libcbor/cbor/internal/loaders.h
+57 −0 source/external/libcbor/cbor/internal/memory_utils.c
+50 −0 source/external/libcbor/cbor/internal/memory_utils.h
+33 −0 source/external/libcbor/cbor/internal/stack.c
+53 −0 source/external/libcbor/cbor/internal/stack.h
+95 −0 source/external/libcbor/cbor/internal/unicode.c
+33 −0 source/external/libcbor/cbor/internal/unicode.h
+190 −0 source/external/libcbor/cbor/ints.c
+211 −0 source/external/libcbor/cbor/ints.h
+125 −0 source/external/libcbor/cbor/maps.c
+121 −0 source/external/libcbor/cbor/maps.h
+368 −0 source/external/libcbor/cbor/serialization.c
+168 −0 source/external/libcbor/cbor/serialization.h
+600 −0 source/external/libcbor/cbor/streaming.c
+37 −0 source/external/libcbor/cbor/streaming.h
+142 −0 source/external/libcbor/cbor/strings.c
+183 −0 source/external/libcbor/cbor/strings.h
+46 −0 source/external/libcbor/cbor/tags.c
+74 −0 source/external/libcbor/cbor/tags.h
+1 −1 source/json.c
+1 −1 source/posix/clock.c
+1 −1 source/priority_queue.c
+1 −0 source/windows/thread.c
+11 −0 tests/CMakeLists.txt
+2 −0 tests/assert_test.c
+58 −1 tests/byte_buf_test.c
+489 −0 tests/cbor_test.c
+18 −14 tests/condition_variable_test.c
+9 −7 tests/error_test.c
+87 −0 tests/fuzz/cbor_decoding_transitive.c
+66 −0 tests/fuzz/cbor_double_encode_decode.c
+0 −1 verification/cbmc/proofs/Makefile.common
+4 −1 verification/cbmc/sources/utils.c
2 changes: 1 addition & 1 deletion crt/aws-lc
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 114cca to 073c7b

0 comments on commit 1424d91

Please sign in to comment.