Skip to content

feat: return object id in TUS upload completion response header#998

Open
oniani1 wants to merge 2 commits intosupabase:masterfrom
oniani1:feat/tus-object-id-header
Open

feat: return object id in TUS upload completion response header#998
oniani1 wants to merge 2 commits intosupabase:masterfrom
oniani1:feat/tus-object-id-header

Conversation

@oniani1
Copy link
Copy Markdown
Contributor

@oniani1 oniani1 commented Apr 9, 2026

Closes #647

Summary

After a TUS resumable upload completes, there's currently no way to get the object_id of the uploaded file without making a follow-up .list() call. The onSuccess callback from tus-js-client only gets the upload URL, not the object ID.

The standard POST /object endpoint already returns the ID in the JSON body ({ Id, Key }). For TUS, since the response format is governed by the protocol, a response header is the natural fit -- same approach @fenos suggested in #647.

This captures the return value of completeUpload() in the onUploadFinish lifecycle hook and includes the object's UUID in a new x-supabase-id response header. The @tus/server library already supports custom headers -- both PatchHandler and PostHandler merge them into the outgoing response.

Changes

  • src/http/routes/tus/lifecycle.ts -- capture completeUpload() result, add x-supabase-id header
  • src/test/tus.test.ts -- new test verifying the header is present, is a valid UUID, and matches the database record

Test plan

  • Added test: TUS upload completion returns x-supabase-id header with valid UUID matching DB record
  • Existing TUS tests pass with no regressions

@oniani1 oniani1 requested a review from a team as a code owner April 9, 2026 18:37
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 24208084802

Coverage decreased (-0.001%) to 80.842%

Details

  • Coverage decreased (-0.001%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37226
Covered Lines: 30272
Line Coverage: 81.32%
Relevant Branches: 4141
Covered Branches: 3170
Branch Coverage: 76.55%
Branches in Coverage %: Yes
Coverage Strength: 320.47 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing object_id in resumable uploads response using TUS

2 participants