Skip to content

bug: S3 - cannot get a file with an expires set in the past. #12890

@franckbrignoliswan

Description

@franckbrignoliswan

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Given a file uploaded on S3 with a expires header set in the past
When I try to retrieve it
Then a NoSuchKey error is returned

An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.

A head request works fine.
A file without expires can be retrieved without any problems

Expected Behavior

The file is found and retrieved.

How are you starting LocalStack?

With a docker run command

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run -e SERVICES=s3 -e DEBUG=1 -e LS_LOG=trace -p 4566:4566 localstack/localstack:4.6

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

MY_BUCKET=my-fancy-bucket
MY_KEY=remote-expired.txt
MY_LOCAL_FILE=local.txt

echo "oui oui" > $MY_LOCAL_FILE

awslocal s3api create-bucket --bucket $MY_BUCKET
awslocal s3api put-object --bucket $MY_BUCKET --key $MY_KEY --expires `date +"%Y-%m-%dT%H:%M:%S%z"` --body $MY_LOCAL_FILE 
awslocal s3api get-object --bucket $MY_BUCKET --key $MY_KEY local-file-expired.txt

awslocal s3api get-object --bucket $MY_BUCKET --key $MY_KEY 

The localstack logs are attached
localstack.log

Environment

- OS: macOs Sequoia 15.5 

- LocalStack:
LocalStack version: 4.6.0 (tried as well on 4.4 and 3.2)
LocalStack build date: 2025-07-03
LocalStack build git hash: b16cabc9b

Anything else?

AWS S3 - SAPI_PutObject_RequestSyntax

Expires
The date and time at which the object is no longer cacheable. For more information, see https://www.rfc-editor.org/rfc/rfc7234#section-5.3.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions