Skip to content

cli: add more precise auth failure messages to error / debug logs - #14992

Merged
ecklf merged 2 commits into
mainfrom
ecklf/token-refresh-log
Feb 17, 2026
Merged

ecklf merged 2 commits into
mainfrom
ecklf/token-refresh-log

Conversation

@ecklf

@ecklf ecklf commented Feb 11, 2026 •

Copy link
Copy Markdown
Member

This PR adds more precise auth error messages to errors / debug logs

Before

Right now you can accidentally inject an env e.g. VERCEL_TOKEN which will lead to confusing error logs.

I just logged in but it says the token is not valid

▲ vc
Vercel CLI 50.15.1
> NOTE: The Vercel CLI now collects telemetry regarding usage of the CLI.
> This information is used to shape the CLI roadmap and prioritize features.
> You can learn more, including how to opt-out if you'd not like to participate in this program, by visiting the following URL:
> https://vercel.com/docs/cli/about-telemetry
> No existing credentials found. Please log in:

  Visit https://vercel.com/oauth/device?user_code=VRND-TNVN

  Congratulations! You are now signed in.

  To deploy something, run `vercel`.

  💡 To deploy every commit automatically,
  connect a Git Repository (vercel.link/git (https://vercel.link/git)).
Error: The specified token is not valid. Use `vercel login` to generate a new token.

It tells me my token is valid, but then the API returns 403, why if it's valid?

▲ vc link --debug
> [debug] [2026-02-11T14:20:46.747Z] Found config in file "/Users/ecklf/Developer/vercel/rust-fluid/vercel.json"
Vercel CLI 50.15.1
> [debug] [2026-02-11T14:20:46.749Z] user supplied known subcommand: "link"
> [debug] [2026-02-11T14:20:46.751Z] Arrived at home directory
> [debug] [2026-02-11T14:20:46.762Z] Found git root via "git rev-parse --show-toplevel" - detected "/Users/ecklf/Developer/vercel/rust-fluid" as repo root
? Set up "~/Developer/vercel/rust-fluid"? yes
> [debug] [2026-02-11T14:20:48.365Z] Spinner invoked (Loading scopes…) with a 1000ms delay
> [debug] [2026-02-11T14:20:48.366Z] Valid access token, skipping token refresh.
> [debug] [2026-02-11T14:20:48.366Z] Valid access token, skipping token refresh.
> [debug] [2026-02-11T14:20:48.386Z] #1 → GET https://api.vercel.com/v2/user
> [debug] [2026-02-11T14:20:48.387Z] #2 → GET https://api.vercel.com/v1/teams
> [debug] [2026-02-11T14:20:48.917Z] #1 ← 403 Forbidden: sfo1::6q2tr-1770819648817-edd83698b280 [531ms]
Error: The specified token is not valid. Use `vercel login` to generate a new token.
> [debug] [2026-02-11T14:20:48.922Z] #2 ← 403 Forbidden: sfo1::bwtp8-1770819648820-0fc2916d7f11 [535ms]

After

Vercel CLI 50.15.1
? Set up and deploy “~/Developer/vercel/rust-fluid”? yes
+ Error: The token provided via VERCEL_TOKEN environment variable is not valid. Please provide a valid token.
Vercel CLI 50.15.1
 [debug] [2026-02-11T14:48:09.628Z] user supplied no target, defaulting to deploy
 [debug] [2026-02-11T14:48:09.643Z] Arrived at home directory
 [debug] [2026-02-11T14:48:09.659Z] Found git root via "git rev-parse --show-toplevel" - detected "/Users/ecklf/Developer/vercel/rust-fluid" as repo root
? Set up and deploy “~/Developer/vercel/rust-fluid”? yes
 [debug] [2026-02-11T14:48:11.040Z] Spinner invoked (Loading scopes…) with a 1000ms delay
 [debug] [2026-02-11T14:48:11.041Z] Using token from VERCEL_TOKEN environment variable, skipping token refresh.
 [debug] [2026-02-11T14:48:11.059Z] #1 → GET https://api.vercel.com/v2/user
 [debug] [2026-02-11T14:48:11.060Z] #2 → GET https://api.vercel.com/v1/teams
(node:96529) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
 [debug] [2026-02-11T14:48:11.656Z] #1 ← 403 Forbidden: sfo1::m6m7m-1770821291563-86622a944cb1 [597ms]
+ Error: The token provided via VERCEL_TOKEN environment variable is not valid. Please provide a valid token.
 [debug] [2026-02-11T14:48:11.660Z] #2 ← 403 Forbidden: sfo1::mkct5-1770821291562-7589b64fc4b4 [600ms]

Note

Low Risk Change

This PR improves error messages by tracking token source (flag vs env var) and displaying more specific error messages when authentication fails, with no changes to authentication logic or security controls.

  • Adds tokenSource field to track whether token came from --token flag or VERCEL_TOKEN env var
  • Updates InvalidToken error class to display source-specific error messages
  • Adds debug logging to indicate token source during refresh checks

Risk assessment for commit e05eb4a.

@ecklf
ecklf requested a review from a team as a code owner February 11, 2026 14:52
@changeset-bot

changeset-bot Bot commented Feb 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e05eb4a

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

This PR includes changesets to release 1 package
Name Type
vercel 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

@github-actions

Copy link
Copy Markdown
Contributor

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-743r9lbao.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-743r9lbao.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Unit Test Strategy

Comparing: ef1be64 → e05eb4a (view diff)

Strategy: Affected packages only

✅ Only testing packages that have been modified or depend on modified packages.

Affected packages - 1 (3%)
  1. vercel
Unaffected packages - 39 (98%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/koa
  24. @vercel/nestjs
  25. @vercel/next
  26. @vercel/node
  27. @vercel/oidc
  28. @vercel/oidc-aws-credentials-provider
  29. @vercel/python
  30. @vercel/python-analysis
  31. @vercel/redwood
  32. @vercel/related-projects
  33. @vercel/remix-builder
  34. @vercel/routing-utils
  35. @vercel/ruby
  36. @vercel/rust
  37. @vercel/static-build
  38. @vercel/static-config
  39. examples

Results

  • Unit tests: Only affected packages will run unit tests
  • E2E tests: Handled separately (Version Packages PRs or run-e2e-tests label)
  • Type checks: Only affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@epallerols epallerols left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ecklf
ecklf merged commit 314aa76 into main Feb 17, 2026
134 checks passed
@ecklf
ecklf deleted the ecklf/token-refresh-log branch February 17, 2026 10:30
mehulkar pushed a commit that referenced this pull request Feb 17, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## [email protected]

### Patch Changes

- Add more precise errors and debug messages for auth issues
([#14992](#14992))

- Add tracing when installing builders
([#15071](#15071))

- Use namespaced vc.builder span attributes (builder.name,
builder.version, builder.dynamicallyInstalled) so they appear correctly
in Datadog and don't conflict with reserved `version` tag
([#15078](#15078))

- non-interactive mode should allow scope argument
([#15077](#15077))


Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — e05eb4ae Deployed Feb 11, 2026 by vercel[bot]
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.

3 participants