fix: improve error message for revoked API tokens with --reach#1145
Merged
Martin Torp (mtorp) merged 2 commits intov1.xfrom Apr 1, 2026
Merged
fix: improve error message for revoked API tokens with --reach#1145Martin Torp (mtorp) merged 2 commits intov1.xfrom
Martin Torp (mtorp) merged 2 commits intov1.xfrom
Conversation
When using `socket scan create --reach` with an invalid or revoked API token, the CLI now shows a clear "Authentication failed" message instead of the misleading "Unable to verify plan permissions" error. Also splits 401/403 handling in the API layer so unauthorized tokens get a distinct message from insufficient permissions. Bumps @coana-tech/cli from 14.12.200 to 14.12.201 and Socket CLI to v1.1.77.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The logger.fail call was running unconditionally, causing unwanted output for callers that pass silence: true (e.g. getDefaultOrgSlug) and double error messages in the 401 reachability flow.
Benjamin Barslev Nielsen (barslev)
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
socket scan create --reachis used with a revoked/invalid API token, the CLI now shows "Authentication failed: Your API token appears to be invalid, expired, or revoked" instead of the misleading "Unable to verify plan permissions" error.getErrorMessageForHttpStatusCodeso each gets a distinct, actionable message across all API calls.@coana-tech/clifrom 14.12.200 to 14.12.201 and Socket CLI to v1.1.77.Test plan
socket scan create --reachwith a revoked API token and verify the error message says "Authentication failed" with token guidancesocket scan create --reachwith a valid token but no enterprise plan and verify the existing "requires an enterprise plan" message still appearssocket scan create --reachwith a valid enterprise token and verify reachability analysis proceeds normallypnpm check(lint + typecheck) passespnpm test:unit src/commands/scan/cmd-scan-create.test.mtspasses (25 tests)Note
Low Risk
Low risk: changes are limited to error handling/messages for HTTP 401/403 and a minor dependency/version bump, with no behavioral changes to scanning beyond clearer failures.
Overview
Improves CLI error handling when running
socket scan create --reachwith invalid/revoked tokens by detecting401 Unauthorizedfrom the organization lookup and returning an explicit Authentication failed message instead of the generic plan-permissions error.Splits
401vs403messaging ingetErrorMessageForHttpStatusCodeso token-invalid and permission-denied cases get distinct guidance across API calls, and adds a failure log infetchOrganizationwhen the org list request fails.Bumps the CLI version to
1.1.77and updates@coana-tech/clito14.12.201(lockfile updated accordingly).Written by Cursor Bugbot for commit 5eac4be. Configure here.