TUS uploads ignore a bucket file_size_limit of 0

Open
#1,667 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@hsusul is already working on this.

Since Nov 5, 2026.

  • #1668 by @hsusul — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
api, backend

Research direction

Start in src/http/routes/tus/index.ts at the TUS server’s maxSize callback, then check how @tus/server handles zero in PostHandler and BaseHandler.calculateMaxBodySize. Reproduce with the zero-limit bucket and both fixed and deferred upload lengths. Done means oversized uploads are rejected with 413 while an upload of length 0 is accepted.

Written by the indexing model from the issue text.

Description

Bug report

A bucket whose file_size_limit is 0 accepts resumable (TUS) uploads of any size. The REST upload path (getStandardMaxFileSizeLimit) and S3 multipart uploads (#1479/#1480) both treat 0 as a real limit. #1480 left the TUS path out of scope.

Two things combine in the TUS server's maxSize callback (src/http/routes/tus/index.ts):

  1. const fileSizeLimit = bucket.file_size_limit || globalFileLimit turns a 0 limit into the global limit.
  2. Changing it to ?? would not be enough on its own. @tus/server treats a maxSize of 0 as "no limit": PostHandler checks maxFileSize > 0 && length > maxFileSize, and BaseHandler.calculateMaxBodySize uses hasConfiguredMaxSizeSet = configuredMaxSize > 0.

The bucket API schema allows 0 (minimum: 0), and bucket create and update store it.

To reproduce

  1. Create a bucket with {"id": "zero", "name": "zero", "file_size_limit": 0}.
  2. Start a resumable upload into it: POST /upload/resumable with Tus-Resumable: 1.0.0, Upload-Length: 1000000 and Upload-Metadata naming bucket zero.
  3. PATCH the bytes.

At upstream 1c49b6a4, step 2 returns 201 Created and the upload completes. Upload-Defer-Length: 1 gets through the same way.

Expected behavior

Step 2 is rejected with 413 (ERR_MAX_SIZE_EXCEEDED), the same way an upload over a positive bucket limit is. An upload with Upload-Length: 0 is still accepted, because an empty object fits a zero-byte limit.

Dominant language
TypeScript
Stars
1.3k
Forks
318
Avg merge
1d 14h
Merged PRs (30d)
106

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/storage

All issues in supabase/storage

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.