Skip to content

fix(storage): improve FileObject type accuracy with nullable fields#2116

Merged
mandarini merged 4 commits into
masterfrom
fix/storage-types-fileobject
Mar 5, 2026
Merged

fix(storage): improve FileObject type accuracy with nullable fields#2116
mandarini merged 4 commits into
masterfrom
fix/storage-types-fileobject

Conversation

@mandarini

@mandarini mandarini commented Feb 12, 2026

Copy link
Copy Markdown
Contributor
  • FileObject: Made id, updated_at, created_at, last_accessed_at, metadata nullable (null for folders)
  • FileObject: Deprecated bucket_id, owner, buckets fields (not returned by list operations)
  • FileObjectV2: Deprecated updated_at field (API returns last_modified)
  • SearchV2Object: Made key optional (sometimes missing in responses)
  • SearchV2Object: Made id, updated_at, created_at, metadata, last_accessed_at nullable (null for folders)
  • Added FileMetadata interface to properly type metadata objects

A clarification on the changes, and whether they are breaking or not:

At runtime, nothing changes. The Storage API has always returned null for id, updated_at, created_at, last_accessed_at, and metadata on folder entries. This is explicitly declared as nullable in the storage/schemas/object.ts. Likewise, bucket_id, owner, and buckets have never been included in list() responses. The previous TypeScript types were incorrect: they promised non-null values that the server never guaranteed, meaning any user code that relied on those guarantees was already silently broken at runtime for folder entries. This PR corrects that lie, the types now accurately reflect what the server has always actually returned. No JavaScript or TypeScript behavior changes. Only the type checker will now correctly surface cases where null-safety wasn't being handled.

@coderabbitai

coderabbitai Bot commented Feb 12, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced experimental V2 API with pagination support for file listings.
    • Added enhanced metadata support including file size, content type, timestamps, and cache control information.
  • Improvements

    • Updated API documentation with clearer guidance on available fields and field availability.
    • Improved distinction between files and folders in search and list results.

Walkthrough

The PR adds a FileMetadata interface and applies it across storage types, replacing prior generic metadata. FileObject fields id, updated_at, created_at, last_accessed_at, and metadata are now nullable and legacy fields (bucket_id, owner, buckets) are optional/deprecated. A new FileObjectV2 models detailed info responses (id, version, name, bucket_id, created_at, last_modified preferred over updated_at, optional size/cache_control/content_type/etag/metadata). SearchV2Object and SearchV2Folder were added/reshaped to include name, id, timestamps and FileMetadata. SearchV2Result now includes folders, objects, hasNext and optional nextCursor. StorageFileApi JSDoc and tests were updated to reflect richer response shapes.


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 and usage tips.

@github-actions github-actions Bot added the storage-js Related to the storage-js library. label Feb 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2116

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2116

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2116

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2116

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2116

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2116

commit: 0bfdb31

@mandarini mandarini self-assigned this Feb 12, 2026
@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from 130799e to f747aa5 Compare February 12, 2026 13:15
@mandarini
mandarini marked this pull request as ready for review February 16, 2026 16:41
@mandarini
mandarini requested review from a team as code owners February 16, 2026 16:41
Comment thread packages/core/storage-js/src/lib/types.ts Outdated
Comment thread packages/core/storage-js/src/lib/types.ts
Comment thread packages/core/storage-js/src/lib/types.ts
Comment thread packages/core/storage-js/src/lib/types.ts
Comment thread packages/core/storage-js/src/lib/types.ts
@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from 475e161 to 6cee1be Compare February 17, 2026 11:41
@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from 6cee1be to 4fa1627 Compare February 17, 2026 12:53
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 82.869%. remained the same
when pulling 4fa1627 on fix/storage-types-fileobject
into 2fe2b51 on master.

Comment thread packages/core/storage-js/src/lib/types.ts
@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from 4fa1627 to 8b8d435 Compare March 3, 2026 11:38
@mandarini
mandarini requested a review from itslenny March 3, 2026 11:45
@mandarini

Copy link
Copy Markdown
Contributor Author

@itslenny addressed your comment

@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from 4e23635 to e33804e Compare March 4, 2026 14:59
@mandarini
mandarini force-pushed the fix/storage-types-fileobject branch from e33804e to d44a4c0 Compare March 4, 2026 15:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/core/storage-js/src/lib/types.ts (1)

132-133: ⚠️ Potential issue | 🟠 Major

FileObjectV2.metadata looks over-constrained for info() responses (Line 133).

FileObjectV2 already models system metadata via top-level fields (size, cache_control, content_type, etag, last_modified). Typing metadata as FileMetadata forces required system keys again and can mis-type valid info() payloads when this field is arbitrary/user metadata.

Proposed type fix
 export interface FileObjectV2 {
@@
-  /** Custom file metadata */
-  metadata?: FileMetadata
+  /** Custom/user metadata returned by info endpoint */
+  metadata?: Record<string, any> | null

As per coding guidelines, "Comment only when the issue must be resolved before merge" and "focus strictly on merge-blocking concerns."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/storage-js/src/lib/types.ts` around lines 132 - 133, The
FileObjectV2.metadata field is too strict (it re-enforces system keys from
FileMetadata and can mis-type arbitrary user metadata returned by info());
change the metadata property on FileObjectV2 from FileMetadata to a loose map
type (e.g., metadata?: Record<string, unknown> or Record<string, any>) so it
accepts arbitrary/user metadata, and update any consumers of
FileObjectV2.metadata to handle the relaxed shape safely (e.g., runtime checks
or key-safe access).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/core/storage-js/src/lib/types.ts`:
- Around line 132-133: The FileObjectV2.metadata field is too strict (it
re-enforces system keys from FileMetadata and can mis-type arbitrary user
metadata returned by info()); change the metadata property on FileObjectV2 from
FileMetadata to a loose map type (e.g., metadata?: Record<string, unknown> or
Record<string, any>) so it accepts arbitrary/user metadata, and update any
consumers of FileObjectV2.metadata to handle the relaxed shape safely (e.g.,
runtime checks or key-safe access).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4449fffa-584b-4b57-a880-5608379ce198

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8d435 and d44a4c0.

📒 Files selected for processing (2)
  • packages/core/storage-js/src/lib/types.ts
  • packages/core/storage-js/src/packages/StorageFileApi.ts

@mandarini
mandarini merged commit c338e2f into master Mar 5, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage-js Related to the storage-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants