Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

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

## [1.1.65](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.65) - 2026-02-26

### Changed
- Improved API error messages to include the request URL, making it easier to debug which endpoint failed

## [1.1.64](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.64) - 2026-02-25

### Changed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket",
"version": "1.1.64",
"version": "1.1.65",
"description": "CLI for Socket.dev",
"homepage": "https://github.com/SocketDev/socket-cli",
"license": "MIT AND OFL-1.1",
Expand Down Expand Up @@ -122,7 +122,7 @@
"@socketregistry/packageurl-js": "1.0.9",
"@socketsecurity/config": "3.0.1",
"@socketsecurity/registry": "1.1.17",
"@socketsecurity/sdk": "1.4.95",
"@socketsecurity/sdk": "1.4.96",
"@socketsecurity/socket-patch": "1.2.0",
"@types/blessed": "0.1.25",
"@types/cmd-shim": "5.0.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions src/utils/api.mts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,11 @@ export async function handleApiCall<T extends SocketSdkOperations>(
const errStr = errCResult.error ? String(errCResult.error).trim() : ''
const message = errStr || NO_ERROR_MESSAGE
const reason = errCResult.cause || NO_ERROR_MESSAGE
const cause =
const baseCause =
reason && message !== reason ? `${message} (reason: ${reason})` : message
const cause = errCResult.url
? `${baseCause} (url: ${errCResult.url})`
: baseCause
const socketSdkErrorResult: ApiCallResult<T> = {
ok: false,
message: 'Socket API error',
Expand Down Expand Up @@ -254,8 +257,11 @@ export async function handleApiCallNoSpinner<T extends SocketSdkOperations>(
: ''
const message = errStr || NO_ERROR_MESSAGE
const reason = sdkErrorResult.cause || NO_ERROR_MESSAGE
const cause =
const baseCause =
reason && message !== reason ? `${message} (reason: ${reason})` : message
const cause = sdkErrorResult.url
? `${baseCause} (url: ${sdkErrorResult.url})`
: baseCause

return {
ok: false,
Expand Down Expand Up @@ -348,12 +354,13 @@ export async function queryApiSafeText(
const errStr = e ? String(e).trim() : ''
const message = 'API request failed'
const rawCause = errStr || NO_ERROR_MESSAGE
const cause = message !== rawCause ? rawCause : ''
const baseCause = message !== rawCause ? rawCause : ''
const cause = baseCause ? `${baseCause} (path: ${path})` : `(path: ${path})`

return {
ok: false,
message,
...(cause ? { cause } : {}),
cause,
}
}

Expand All @@ -366,7 +373,7 @@ export async function queryApiSafeText(
return {
ok: false,
message: 'Socket API error',
cause: `${result.statusText} (reason: ${await getErrorMessageForHttpStatusCode(status)})`,
cause: `${result.statusText} (reason: ${await getErrorMessageForHttpStatusCode(status)}) (path: ${path})`,
data: {
code: status,
},
Expand All @@ -386,7 +393,7 @@ export async function queryApiSafeText(
return {
ok: false,
message: 'API request failed',
cause: 'Unexpected error reading response text',
cause: `Unexpected error reading response text (path: ${path})`,
}
}
}
Expand Down Expand Up @@ -495,12 +502,13 @@ export async function sendApiRequest<T>(
const errStr = e ? String(e).trim() : ''
const message = 'API request failed'
const rawCause = errStr || NO_ERROR_MESSAGE
const cause = message !== rawCause ? rawCause : ''
const baseCause = message !== rawCause ? rawCause : ''
const cause = baseCause ? `${baseCause} (path: ${path})` : `(path: ${path})`

return {
ok: false,
message,
...(cause ? { cause } : {}),
cause,
}
}

Expand All @@ -513,7 +521,7 @@ export async function sendApiRequest<T>(
return {
ok: false,
message: 'Socket API error',
cause: `${result.statusText} (reason: ${await getErrorMessageForHttpStatusCode(status)})`,
cause: `${result.statusText} (reason: ${await getErrorMessageForHttpStatusCode(status)}) (path: ${path})`,
data: {
code: status,
},
Expand All @@ -532,7 +540,7 @@ export async function sendApiRequest<T>(
return {
ok: false,
message: 'API request failed',
cause: 'Unexpected error parsing response JSON',
cause: `Unexpected error parsing response JSON (path: ${path})`,
}
}
}