Skip to content

get_object() complains about wrong bucket name #1336

@best2come

Description

@best2come

Describe the bug

I'm using version 1.100.0 of aws-sdk-s3 and localstack for testing.
I'm trying to get the input bucket with get_object() and providing the bucket name with bucket() and the key with key().

With the following code:

    let input_bucket = "input-bucket-name";
    let input_key = "test.txt";

    // Read the file from S3
    let get_object_output = client
        .get_object()
        .bucket(input_bucket)
        .key(input_key)
        .send()
        .await?;

I get the error message NoSuchBucket. Both, the bucket and the file exist. I've checked this.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Object to be able to read the file contents.

Current Behavior

I get the error response (NoSuchBucket with the BucketName: test.txt):

ERROR Lambda runtime invoke{requestId="03efabd0-0853-4380-ae98-f27e473aba52" xrayTraceId="Root=1-688faa3a-b286a3587fa26037015954f2;Parent=3f4b7c405d5a85b8;Sampled=1"}: lambda_runtime::layers::panic: ServiceError(ServiceError { source: Unhandled(Unhandled { source: ErrorMetadata { code: Some("NoSuchBucket"), message: Some("The specified bucket does not exist"), extras: Some({"s3_extended_request_id": "s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234=", "aws_request_id": "b4042e17-c962-42f6-9353-4129f7f936c5"}) }, meta: ErrorMetadata { code: Some("NoSuchBucket"), message: Some("The specified bucket does not exist"), extras: Some({"s3_extended_request_id": "s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234=", "aws_request_id": "b4042e17-c962-42f6-9353-4129f7f936c5"}) } }), raw: Response { status: StatusCode(404), headers: Headers { headers: {"server": HeaderValue { _private: H1("TwistedWeb/24.3.0") }, "date": HeaderValue { _private: H1("Sun, 03 Aug 2025 18:28:10 GMT") }, "content-type": HeaderValue { _private: H1("application/xml") }, "content-length": HeaderValue { _private: H1("225") }, "x-amz-request-id": HeaderValue { _private: H1("b4042e17-c962-42f6-9353-4129f7f936c5") }, "x-amz-id-2": HeaderValue { _private: H1("s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234=") }, "x-localstack": HeaderValue { _private: H1("true") }} }, body: SdkBody { inner: Once(Some(b"<?xml version='1.0' encoding='utf-8'?>\n<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><RequestId>b4042e17-c962-42f6-9353-4129f7f936c5</RequestId><BucketName>test.txt</BucketName></Error>")), retryable: true }, extensions: Extensions { extensions_02x: Extensions, extensions_1x: Extensions } } })

Reproduction Steps

When I set the key to the same name as the bucket, then I get the response:

GetObjectOutput { body: ByteStream { inner: Inner { body: SdkBody { inner: BoxBody, retryable: false } } }, delete_marker: None, accept_ranges: None, expiration: None, restore: None, last_modified: None, content_length: Some(632), e_tag: None, checksum_crc32: None, checksum_crc32_c: None, checksum_crc64_nvme: None, checksum_sha1: None, checksum_sha256: None, checksum_type: None, missing_meta: None, version_id: None, cache_control: None, content_disposition: None, content_encoding: None, content_language: None, content_range: None, content_type: Some("application/xml"), website_redirect_location: None, server_side_encryption: None, metadata: Some({}), sse_customer_algorithm: None, sse_customer_key_md5: None, ssekms_key_id: "*** Sensitive Data Redacted ***", bucket_key_enabled: None, storage_class: None, request_charged: None, replication_status: None, parts_count: None, tag_count: None, object_lock_mode: None, object_lock_retain_until_date: None, object_lock_legal_hold_status: None, expires: None, expires_string: None, _extended_request_id: Some("s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234="), _request_id: Some("5868284c-96fc-4697-87ea-dec29569966c") }

Possible Solution

No response

Additional Information/Context

No response

Version

├── aws-config v1.8.3
│   ├── aws-credential-types v1.2.4
│   │   ├── aws-smithy-async v1.2.5
│   │   ├── aws-smithy-runtime-api v1.8.5
│   │   │   ├── aws-smithy-async v1.2.5 (*)
│   │   │   ├── aws-smithy-types v1.3.2
│   │   ├── aws-smithy-types v1.3.2 (*)
│   ├── aws-runtime v1.5.9
│   │   ├── aws-credential-types v1.2.4 (*)
│   │   ├── aws-sigv4 v1.3.3
│   │   │   ├── aws-credential-types v1.2.4 (*)
│   │   │   ├── aws-smithy-eventstream v0.60.10
│   │   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   │   ├── aws-smithy-http v0.62.2
│   │   │   │   ├── aws-smithy-eventstream v0.60.10 (*)
│   │   │   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-smithy-async v1.2.5 (*)
│   │   ├── aws-smithy-eventstream v0.60.10 (*)
│   │   ├── aws-smithy-http v0.62.2 (*)
│   │   ├── aws-smithy-runtime v1.8.5
│   │   │   ├── aws-smithy-async v1.2.5 (*)
│   │   │   ├── aws-smithy-http v0.62.2 (*)
│   │   │   ├── aws-smithy-http-client v1.0.6
│   │   │   │   ├── aws-smithy-async v1.2.5 (*)
│   │   │   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   │   │   │   │   ├── aws-lc-rs v1.13.3
│   │   │   │   │   │   │   ├── aws-lc-sys v0.30.0
│   │   │   │   │   │   │   ├── aws-lc-rs v1.13.3 (*)
│   │   │   ├── aws-smithy-observability v0.1.3
│   │   │   │   └── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-types v1.3.8
│   │   │   ├── aws-credential-types v1.2.4 (*)
│   │   │   ├── aws-smithy-async v1.2.5 (*)
│   │   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   │   ├── aws-smithy-types v1.3.2 (*)
│   ├── aws-sdk-sso v1.78.0
│   │   ├── aws-credential-types v1.2.4 (*)
│   │   ├── aws-runtime v1.5.9 (*)
│   │   ├── aws-smithy-async v1.2.5 (*)
│   │   ├── aws-smithy-http v0.62.2 (*)
│   │   ├── aws-smithy-json v0.61.4
│   │   │   └── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-smithy-runtime v1.8.5 (*)
│   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-types v1.3.8 (*)
│   ├── aws-sdk-ssooidc v1.79.0
│   │   ├── aws-credential-types v1.2.4 (*)
│   │   ├── aws-runtime v1.5.9 (*)
│   │   ├── aws-smithy-async v1.2.5 (*)
│   │   ├── aws-smithy-http v0.62.2 (*)
│   │   ├── aws-smithy-json v0.61.4 (*)
│   │   ├── aws-smithy-runtime v1.8.5 (*)
│   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-types v1.3.8 (*)
│   ├── aws-sdk-sts v1.80.0
│   │   ├── aws-credential-types v1.2.4 (*)
│   │   ├── aws-runtime v1.5.9 (*)
│   │   ├── aws-smithy-async v1.2.5 (*)
│   │   ├── aws-smithy-http v0.62.2 (*)
│   │   ├── aws-smithy-json v0.61.4 (*)
│   │   ├── aws-smithy-query v0.60.7
│   │   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-smithy-runtime v1.8.5 (*)
│   │   ├── aws-smithy-runtime-api v1.8.5 (*)
│   │   ├── aws-smithy-types v1.3.2 (*)
│   │   ├── aws-smithy-xml v0.60.10
│   │   ├── aws-types v1.3.8 (*)
│   ├── aws-smithy-async v1.2.5 (*)
│   ├── aws-smithy-http v0.62.2 (*)
│   ├── aws-smithy-json v0.61.4 (*)
│   ├── aws-smithy-runtime v1.8.5 (*)
│   ├── aws-smithy-runtime-api v1.8.5 (*)
│   ├── aws-smithy-types v1.3.2 (*)
│   ├── aws-types v1.3.8 (*)
├── aws-sdk-s3 v1.100.0
│   ├── aws-credential-types v1.2.4 (*)
│   ├── aws-runtime v1.5.9 (*)
│   ├── aws-sigv4 v1.3.3 (*)
│   ├── aws-smithy-async v1.2.5 (*)
│   ├── aws-smithy-checksums v0.63.5
│   │   ├── aws-smithy-http v0.62.2 (*)
│   │   ├── aws-smithy-types v1.3.2 (*)
│   ├── aws-smithy-eventstream v0.60.10 (*)
│   ├── aws-smithy-http v0.62.2 (*)
│   ├── aws-smithy-json v0.61.4 (*)
│   ├── aws-smithy-runtime v1.8.5 (*)
│   ├── aws-smithy-runtime-api v1.8.5 (*)
│   ├── aws-smithy-types v1.3.2 (*)
│   ├── aws-smithy-xml v0.60.10 (*)
│   ├── aws-types v1.3.8 (*)

Environment details (OS name and version, etc.)

Ubuntu 24.04

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.closed-for-stalenessresponse-requestedWaiting on additional info and feedback. Will move to 'closing-soon' in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions