Skip to content

fix(blob): include HTTP status in error when client token retrieval fails#1042

Open
matingathani wants to merge 2 commits intovercel:mainfrom
matingathani:fix/blob-client-token-error-message
Open

fix(blob): include HTTP status in error when client token retrieval fails#1042
matingathani wants to merge 2 commits intovercel:mainfrom
matingathani:fix/blob-client-token-error-message

Conversation

@matingathani
Copy link
Copy Markdown
Contributor

Summary

Closes #488

When upload() fails to retrieve a client token from handleUploadUrl (e.g. the route returns 401 or 403 because the user isn't authenticated), the error message previously said:

Vercel Blob: Failed to  retrieve the client token

(also had a double-space typo)

It now includes the HTTP status code and status text:

Vercel Blob: Failed to retrieve the client token: 403 Forbidden

This gives developers immediately actionable context without making any assumptions about the format of the response body.

Changes

  • packages/blob/src/client.ts — include res.status and res.statusText in the error message; fix double-space typo
  • packages/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 changeset

Test plan

  • pnpm test in packages/blob — all tests pass
  • upload() with a handleUploadUrl that returns 403 → error message includes 403 Forbidden

…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
Copilot AI review requested due to automatic review settings April 2, 2026 20:16
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

@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-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: f78dd76

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/blob Patch
vercel-storage-integration-test-suite Patch

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 include res.status and res.statusText in the thrown BlobError when res.ok is 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.

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.

@vercel/blob - Return more useful error message when retrieveClientToken throws

2 participants