fix(blob): respect server pathname in handleUpload#1043
fix(blob): respect server pathname in handleUpload#1043matingathani wants to merge 2 commits intovercel:mainfrom
Conversation
|
@matingathani is attempting to deploy a commit to the Curated Tests - Permanent E2E Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: f4e2dc6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR fixes handleUpload() so that when onBeforeGenerateToken() returns an overridden pathname, that server-controlled pathname is used when generating the client token.
Changes:
- Update
handleUpload()to prefer apathnamereturned fromonBeforeGenerateToken()when generating the client token. - Add a Node test covering pathname override behavior in generated client tokens.
- Add a changeset documenting the patch change for
@vercel/blob.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/blob/src/client.ts | Uses server-returned pathname override when generating the client token in handleUpload(). |
| packages/blob/src/client.node.test.ts | Adds regression test asserting the overridden pathname is embedded in the generated client token. |
| .changeset/fix-blob-handle-upload-pathname.md | Documents the behavior change as a patch release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const { | ||
| callbackUrl: providedCallbackUrl, | ||
| pathname: overriddenPathname, | ||
| ...tokenOptions | ||
| } = payload; |
There was a problem hiding this comment.
payload is typed as the return value of onBeforeGenerateToken, but HandleUploadOptions['onBeforeGenerateToken'] currently does not include a pathname field in its return type (see packages/blob/src/client.ts around the HandleUploadOptions definition). Destructuring pathname: overriddenPathname here (and returning { pathname: ... } in tests/user code) will fail TypeScript type-checking. Update the onBeforeGenerateToken return type to allow an optional pathname override (and ideally document it) so this change is type-safe.
|
Addressed the type-safety gap here. |
No description provided.