Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When the DISABLE_CUSTOM_CORS_S3=1
env variable is set, this affects LocalStack's handling of S3 PutObject
calls with a Content-Encoding: gzip
. Attempting to put an object like this (see commands below) results in a checksum error:
An error occurred (BadDigest) when calling the PutObject operation: The CRC64NVME you specified did not match the calculated checksum.
The reason for this appears to be the object has seemingly been decoded ahead of being stored in LocalStack. The reason this appears to be the case is that when disabling payload verification via an SDK and putting the object, the object is stored in LocalStack successfully but like so from HeadObject
response:
AcceptRanges: bytes
ContentEncoding: identity
ContentLength: 6
ContentType: text/plain
ETag: '"605f1ecb0bf8fc6fdef2a4e4983e7478"'
LastModified: '2025-07-11T00:19:01+00:00'
Metadata: {}
ServerSideEncryption: AES256
The original text file is hello
(6 bytes) and when gzipped is 35 bytes. Running GetObject
on this object returns the decoded text and not the gzipped content which was sent and should have been stored.
The ContentEncoding: identity
is non-standard behaviour - production AWS (and LocalStack itself when DISABLE_CUSTOM_CORS_S3=0
) stores this with ContentEncoding: gzip
and the object remains encoded when stored/retrieved.
This doesn't appear to affect either br
or deflate
codings - these are stored correctly and don't fail checksum validation on PutObject
when DISABLE_CUSTOM_CORS_S3=1
is set.
Expected Behavior
Behaves like production AWS (and LocalStack itself when DISABLE_CUSTOM_CORS_S3=0
): an object put with Content-Encoding: gzip
is stored as-is and when retrieved, is returned with the same gzip
encoding.
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack
command, arguments, or docker-compose.yml
)
services:
localstack:
image: localstack/localstack:4.6.0
ports:
- 4566:4566
environment:
- DEBUG=1
- DISABLE_CUSTOM_CORS_S3=1
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
$ echo 'hello' > test.txt
$ gzip test.txt
$ awslocal s3api create-bucket --bucket test
$ awslocal s3api put-object --bucket test --content-encoding gzip --content-type text/plain --key test.txt --body test.txt.gz
An error occurred (BadDigest) when calling the PutObject operation: The CRC64NVME you specified did not match the calculated checksum.
Environment
- OS: Ubuntu 24.04
- LocalStack:
LocalStack version: `4.6.0`
LocalStack Docker image sha: `sha256:467827579d31ecce01c13eccc57961d02424a87911b0ba96df8a2801183c8f59`
LocalStack build date: `2025-07-03`
LocalStack build git hash: `b16cabc9b`
Anything else?
No response