Repository navigation
Conversation
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.
|
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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 SummarySummary by CodeRabbit
Walkthrough
Priority: ⬇️ Low Change: Bug fix Merge Risk: ⚪ Minimal · up to The change appears ready to merge after normal checks. No actionable risk remains in the supplied evidence. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to 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 Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
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. Comment |
111dc08 to
561afb3
Compare
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' }, witherror: null. Nested keys get renamed too.What changed?
info()now camelCases only the top-level response fields (bucket_id,content_type,last_modified, ...) and passesmetadatathrough 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 throughrecursiveToCamel, and that function also walks intometadata. On the server,/object/infofillsmetadatawith the object'suser_metadata, which is exactly what the caller passed toupload({ 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 getsundefined.The return type already agrees with this.
Camelize<FileObjectV2>only renames top-level keys, so the types saidmetadatawould 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 calledinfo().Before:
After:
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
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
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formattingAdditional notes
FileObjectV2.metadatais typed asFileMetadata(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.