Skip to content

fix(storage): return user metadata keys unchanged from info() - #2712

Open
Shub3am wants to merge 1 commit into
supabase:masterfrom
Shub3am:fix/storage-info-user-metadata
Open

Shub3am wants to merge 1 commit into
supabase:masterfrom
Shub3am:fix/storage-info-user-metadata

Conversation

@Shub3am

@Shub3am Shub3am commented Sep 26, 2026

Copy link
Copy Markdown

Description

storage.from(bucket).info(path) hands back your own upload metadata with the keys renamed. If you upload with { metadata: { user_id: 'u-42', 'x-source-app': 'mobile' } }, info() gives you { userId: 'u-42', xSourceApp: 'mobile' }, with error: null. Nested keys get renamed too.

What changed?

info() now camelCases only the top-level response fields (bucket_id, content_type, last_modified, ...) and passes metadata through as-is. I also added a unit test with a mocked fetch that covers snake_case, kebab-case and nested metadata keys.

Why was this change needed?

info() ran the whole response through recursiveToCamel, and that function also walks into metadata. On the server, /object/info fills metadata with the object's user_metadata, which is exactly what the caller passed to upload({ metadata }). Those are user-owned keys, so the SDK shouldn't be rewriting them. Anyone who looks up a key by the name they stored it under gets undefined.

The return type already agrees with this. Camelize<FileObjectV2> only renames top-level keys, so the types said metadata would be untouched while the runtime changed it.

I couldn't find an existing issue for this. I hit it while reading the storage client and then confirmed it against a local Supabase stack.

Screenshots/Examples

I uploaded { user_id: 'u-42', 'x-source-app': 'mobile', nested: { order_id: 7 } } to a local stack and called info().

Before:

server raw metadata     : {"nested":{"order_id":7},"user_id":"u-42","x-source-app":"mobile"}
info() error            : null
info().data.metadata    : {"nested":{"orderId":7},"userId":"u-42","xSourceApp":"mobile"}
metadata round-trips    : false

After:

info().data.metadata    : {"nested":{"order_id":7},"user_id":"u-42","x-source-app":"mobile"}
metadata round-trips    : true

The new test fails on master and passes with the fix. The full storage-js suite passes against the local stack (19 suites, 424 passed, 2 skipped).

Breaking changes

  • This PR contains no breaking changes

The one behaviour change is that metadata keys come back exactly as they were uploaded. Keys without _ or - (like the ones in the existing "custom metadata" test) behave the same as before.

Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run pnpm nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

Additional notes

FileObjectV2.metadata is typed as FileMetadata (the system metadata shape), even though the server sends user metadata there. I left the type alone to keep this PR small. Happy to follow up on it if you'd like.

info() ran the whole response through recursiveToCamel, which also walked
into `metadata`. The storage server fills that field with the object's
user_metadata (whatever was passed to upload({ metadata })), so keys like
user_id or x-source-app came back as userId / xSourceApp, at every
nesting level. The Camelize<FileObjectV2> return type is shallow, so the
types already said metadata should be untouched.

Camel-case only the top-level fields and pass metadata through as-is.
@Shub3am
Shub3am requested review from a team as code owners September 26, 2026 18:49
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 87186c58-0183-49e8-827f-882e11655fa9

📥 Commits

Reviewing files that changed from the base of the PR and between 6d21e3f and 111dc08.

📒 Files selected for processing (2)
  • packages/core/storage-js/src/packages/StorageFileApi.ts
  • packages/core/storage-js/test/info-user-metadata.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
    • File information fields are converted to camelCase while user metadata retains its original key casing and structure.

Walkthrough

StorageFileApi.info() now camelizes file information without changing the metadata object. A test checks that top-level fields are camelized, metadata keys and nested values remain unchanged, and the call returns no error.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 111dc

The change appears ready to merge after normal checks. No actionable risk remains in the supplied evidence.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 111dc

The change preserves user-supplied metadata keys without changing how objects are fetched or who can access them. No new security-sensitive behavior was identified, although applications that relied on the old key names may need to adjust.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The observable change reaches consumers of storage info() responses for objects whose metadata keys would previously have been converted; it does not itself extend object access.

Trust Boundaries and Controls

  • observed — The existing info() request still supplies the client's headers. This client-side change does not establish what checks the server applies, but it does not remove a check visible in this entrypoint.

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.

@Shub3am
Shub3am force-pushed the fix/storage-info-user-metadata branch from 111dc08 to 561afb3 Compare October 1, 2026 03:49

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.

1 participant