Skip to content

fix(storage): ignore undefined upload options - #2789

Open
pintu544 wants to merge 1 commit into
supabase:masterfrom
pintu544:fix/storage-undefined-options
Open

pintu544 wants to merge 1 commit into
supabase:masterfrom
pintu544:fix/storage-undefined-options

Conversation

@pintu544

Copy link
Copy Markdown

Summary

When optional FileOptions are explicitly undefined, spreading them over the defaults replaces those defaults. Raw uploads can send headers such as cache-control: max-age=undefined and content-type: undefined; multipart uploads can send the cacheControl field as "undefined".

Ignore undefined-valued options before applying defaults in regular and signed uploads. Explicitly allow undefined for cacheControl, contentType, and upsert so callers using exactOptionalPropertyTypes can express this behavior. Add regression coverage for raw headers and multipart cache control across upload, update, and uploadToSignedUrl.

Closes #2788.

Validation

  • Focused upload tests: 60 passed.
  • Storage package build passed.
  • Prettier and git diff --check passed.
  • The full Docker-backed storage test suite was not run because Docker is unavailable. The Nx build target could not initialize the workspace graph with the filtered install; the direct storage package build passed.

Filter undefined file options before applying upload defaults so documented values are preserved.

fix supabase#2788
@pintu544
pintu544 requested review from a team as code owners October 23, 2026 19:00
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d30c4de-2227-4c6c-a360-acf9cfb0445e
📥 Commits

Reviewing files that changed from the base of the PR and between 51816da and 91bd60e.

📒 Files selected for processing: 3
  • packages/core/storage-js/src/lib/types.ts
  • packages/core/storage-js/src/packages/StorageFileApi.ts
  • packages/core/storage-js/test/storageFileApiUpload.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Uploads and updates now retain default file settings when an option is explicitly set to undefined. This applies to regular uploads, updates, and signed-URL uploads, including the default cache duration.
  • Tests
    • Added coverage to verify default settings are applied consistently across these upload methods.

The storage file option types now explicitly allow undefined. Upload, update, and signed-upload paths filter out undefined option values before merging with defaults. Tests cover default headers and multipart cache-control fields when options are explicitly undefined.

Assessment against linked issues

Objective Addressed Explanation
Handle explicitly undefined upload options by using documented defaults across upload, update, signed uploads, and multipart bodies [#2788] ✅

Priority: ➖ Normal

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 91bd6

The change preserves documented upload defaults for explicitly undefined options without introducing an identified merge-blocking risk.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

storage upload() sends "undefined" headers when an option is passed as undefined

1 participant