Skip to content

Commit 5eac4be

Browse files
committed
fix: improve error message for revoked API tokens with --reach
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.
1 parent 8b492f4 commit 5eac4be

File tree

6 files changed

+71
-8
lines changed

6 files changed

+71
-8
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.1.77](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.77) - 2026-04-01
8+
9+
### Fixed
10+
- Improved error message when using `--reach` with an invalid, expired, or revoked API token. Previously showed a misleading "Unable to verify plan permissions" error; now clearly indicates the authentication failure.
11+
12+
### Changed
13+
- Updated the Coana CLI to v `14.12.201`.
14+
715
## [1.1.74](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.74) - 2026-03-19
816

917
### Fixed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket",
3-
"version": "1.1.76",
3+
"version": "1.1.77",
44
"description": "CLI for Socket.dev",
55
"homepage": "https://github.com/SocketDev/socket-cli",
66
"license": "MIT AND OFL-1.1",
@@ -97,7 +97,7 @@
9797
"@babel/preset-typescript": "7.27.1",
9898
"@babel/runtime": "7.28.4",
9999
"@biomejs/biome": "2.2.4",
100-
"@coana-tech/cli": "14.12.200",
100+
"@coana-tech/cli": "14.12.201",
101101
"@cyclonedx/cdxgen": "12.1.2",
102102
"@dotenvx/dotenvx": "1.49.0",
103103
"@eslint/compat": "1.3.2",

pnpm-lock.yaml

Lines changed: 45 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/organization/fetch-organization-list.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { logger } from '@socketsecurity/registry/lib/logger'
2+
13
import { handleApiCall } from '../../utils/api.mts'
24
import { setupSdk } from '../../utils/sdk.mts'
35

@@ -54,6 +56,7 @@ export async function fetchOrganization(
5456
silence,
5557
})
5658
if (!orgsCResult.ok) {
59+
logger.fail(orgsCResult.message, orgsCResult.cause)
5760
return orgsCResult
5861
}
5962

src/commands/scan/perform-reachability-analysis.mts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ export async function performReachabilityAnalysis(
7575
// Check if user has enterprise plan for reachability analysis.
7676
const orgsCResult = await fetchOrganization()
7777
if (!orgsCResult.ok) {
78+
const httpCode = (orgsCResult.data as { code?: number } | undefined)?.code
79+
if (httpCode === constants.HTTP_STATUS_UNAUTHORIZED) {
80+
return {
81+
ok: false,
82+
message: 'Authentication failed',
83+
cause:
84+
'Your API token appears to be invalid, expired, or revoked. Please check your token and try again.',
85+
}
86+
}
7887
return {
7988
ok: false,
8089
message: 'Unable to verify plan permissions',

src/utils/api.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,10 @@ export async function getErrorMessageForHttpStatusCode(code: number) {
248248
if (code === HTTP_STATUS_BAD_REQUEST) {
249249
return 'One of the options passed might be incorrect'
250250
}
251-
if (code === HTTP_STATUS_FORBIDDEN || code === HTTP_STATUS_UNAUTHORIZED) {
251+
if (code === HTTP_STATUS_UNAUTHORIZED) {
252+
return 'Your Socket API token appears to be invalid, expired, or revoked. Please verify your token is correct and active'
253+
}
254+
if (code === HTTP_STATUS_FORBIDDEN) {
252255
return 'Your Socket API token may not have the required permissions for this command or you might be trying to access (data from) an organization that is not linked to the API token you are logged in with'
253256
}
254257
if (code === HTTP_STATUS_NOT_FOUND) {

0 commit comments

Comments
 (0)