Skip to content

bug: ContentLength not set on Java SDK 2.0 when performing S3 get-object #9294

@dominic-jones

Description

@dominic-jones

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

This sounds like a regression of this issue: #631 . The description there sounds the same as what we're experiencing.

After upgrading to localstack 2.2 (and persists to 2.3), our AWS SDK now receives a null ContentLength returned on getting an S3 object.

When performing the same check with the AWS CLI, the ContentLength is returned correctly.

I compared some exact headers using WireShark.

This compares WireShark outputs: left AWS SDK on localstack 2.1, right is AWS SDK on localstack 2.2:
aws cli and aws sdk localstack 2-2

This is both localstack 2.2, left is the AWS CLI, right is the AWS SDK:
aws sdk localstack 2-1 and 2-2

Expected Behavior

When getting an object from S3, the ContentLength should be returned to the AWS SDK.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

Docker commands

I don't have access to these, sorry. There's a layer of company scripting in front that obscures the exact command.

AWS SDK Execution

        val request = GetObjectRequest.builder()
            .bucket(actualS3BucketName)
            .key(s3Key)
            .apply { range?.let { range(HttpRange.toString(listOf(it))) } }
            .build()
        val respTransformer = SyncGetObjectResponseTransformer()
        return this.objectSyncClient
            .getObject(request, respTransformer)

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

aws s3api get-object --bucket s3-objects \
  --key "$key" \
  output-file-name \
  --endpoint-url http://localhost:4566 --profile localstack

Environment

OS: Ubuntu 22.04
AWS SDK: 2.20.159
localstack: 2.2.0 (also 2.3.0 using v2 provider)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

aws:s3Amazon Simple Storage Servicestatus: resolved/fixedResolved with a fix or an implementationtype: bugBug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions