Skip to content

bug: content-length-range not respected #12448

@paciops

Description

@paciops

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The condition content-length-range is not respect in localstack S3.

Lunching localstack with docker run --rm -p 4566:4566 -e localstack/localstack:s3-latest and this test in node.js https://gist.github.com/paciops/c69e6d7dee4b0454758b2bf45d0c5bad shows how it is possible to upload files with size out of range.
Test log:

Bucket created
▶ File Upload
  ✖ should not upload a oversize file with POST (47.503439ms)
    AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
    
    204 !== 400
    
        at TestContext.<anonymous> (/home/test/integration/gist.ts:87:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async Test.run (node:internal/test_runner/test:935:9)
        at async Promise.all (index 0)
        at async Suite.run (node:internal/test_runner/test:1320:7)
        at async startSubtestAfterBootstrap (node:internal/test_runner/harness:296:3) {
      generatedMessage: true,
      code: 'ERR_ASSERTION',
      actual: 204,
      expected: 400,
      operator: 'strictEqual'
    }

  ✖ should not upload a undersize file with POST (74.76786ms)
    AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
    
    204 !== 400
    
        at TestContext.<anonymous> (/home/test/integration/gist.ts:107:5)
        at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
        at async Test.run (node:internal/test_runner/test:935:9)
        at async Suite.processPendingSubtests (node:internal/test_runner/test:633:7) {
      generatedMessage: true,
      code: 'ERR_ASSERTION',
      actual: 204,
      expected: 400,
      operator: 'strictEqual'
    }

✖ File Upload (407.059509ms)
ℹ tests 2
ℹ suites 1
ℹ pass 0
ℹ fail 2
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 1505.248712

Expected Behavior

Responses should be 400 and 204

How are you starting LocalStack?

docker run --rm -p 4566:4566 -e localstack/localstack:s3-latest

Steps To Reproduce

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

docker run --rm -p 4566:4566 -e localstack/localstack:s3-latest

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

See this gist file

Environment

- OS: opensuse tumbleweed
- LocalStack:
  LocalStack version: 4.3.1.dev1
  LocalStack Docker image sha: 6e16ae4d5f93
  LocalStack build date: 2025-03-27
  LocalStack build git hash: 4125b0183

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions