fix(blob): include HTTP status in error when client token retrieval fails#1042
fix(blob): include HTTP status in error when client token retrieval fails#1042matingathani wants to merge 2 commits intovercel:mainfrom
Conversation
…ails Replaces the vague 'Failed to retrieve the client token' message (also fixing the double-space typo) with one that includes the HTTP status code and status text, making auth errors (401, 403) easier to diagnose. Closes vercel#488
|
@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: f78dd76 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
Improves the developer-facing error when upload() cannot retrieve a client token from handleUploadUrl by including the HTTP status code and status text (and fixing a typo), making authentication/authorization failures immediately clearer.
Changes:
- Update
retrieveClientToken()to includeres.statusandres.statusTextin the thrownBlobErrorwhenres.okis false. - Add a browser-client test asserting the new error message format for a non-ok token response.
- Add a patch changeset documenting the behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/blob/src/client.ts | Enhances the non-ok client-token retrieval error message with HTTP status context. |
| packages/blob/src/client.browser.test.ts | Adds coverage to ensure the new error message includes status and status text. |
| .changeset/fix-blob-client-token-error-message.md | Publishes the change as a patch with a short explanation and issue closure. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Closes #488
When
upload()fails to retrieve a client token fromhandleUploadUrl(e.g. the route returns 401 or 403 because the user isn't authenticated), the error message previously said:(also had a double-space typo)
It now includes the HTTP status code and status text:
This gives developers immediately actionable context without making any assumptions about the format of the response body.
Changes
packages/blob/src/client.ts— includeres.statusandres.statusTextin the error message; fix double-space typopackages/blob/src/client.browser.test.ts— add test asserting the error message format on a non-ok response.changeset/fix-blob-client-token-error-message.md— patch changesetTest plan
pnpm testinpackages/blob— all tests passupload()with ahandleUploadUrlthat returns 403 → error message includes403 Forbidden