Skip to content

feat: include request URL in API error messages#1094

Merged
jdalton merged 1 commit intov1.xfrom
add-url-to-api-errors
Feb 26, 2026
Merged

feat: include request URL in API error messages#1094
jdalton merged 1 commit intov1.xfrom
add-url-to-api-errors

Conversation

@mtorp
Copy link
Contributor

@mtorp mtorp commented Feb 26, 2026

Problem

When a Socket API request fails, the CLI displays an error like:

✖  Socket API error:  Socket API POST request failed (400):

This lacks the request URL, making it difficult to debug which endpoint failed — especially when multiple API calls are involved in a single command.

Solution

Surface the failing endpoint URL in all API error messages. Two complementary approaches:

SDK-routed calls (handleApiCall, handleApiCallNoSpinner): Read the new url field from SocketSdkErrorResult (added in @socketsecurity/sdk 1.4.96, SocketDev/socket-sdk-js#483) and append it to the cause string.

Direct-fetch calls (queryApiSafeText, sendApiRequest): Append the request path to all error cause strings — the catch block, the !result.ok branch, and the response parsing error.

Example output after this change

✖  Socket API error:  Socket API POST request failed (404): Not Found (reason: Organization not found) (url: https://api.socket.dev/v0/orgs/badorg/full-scans?branch=main&scan_type=socket&repo=my-repo)

Changes

  • src/utils/api.mts: Updated handleApiCall, handleApiCallNoSpinner, queryApiSafeText, and sendApiRequest to include URL/path in error messages
  • package.json: Bumped @socketsecurity/sdk to 1.4.96, version to 1.1.65
  • CHANGELOG.md: Added entry for 1.1.65

Test plan

  • Build passes (pnpm build:dist:src)
  • Type check passes (pnpm check:tsc)
  • Lint passes (pnpm check:lint)
  • Manually verified with socket scan create --org nonexistent-org — URL appears in error output

Note

Low Risk
Low risk: changes are limited to error-message formatting and a minor @socketsecurity/sdk patch bump; main potential impact is downstream tests/log parsing expecting the old cause strings.

Overview
Improves CLI debuggability by appending the failing endpoint to all Socket API error causes: SDK-routed failures now include errCResult.url, and direct fetch helpers (queryApiSafeText, sendApiRequest) always include the request path in catch, non-OK response, and parse/read failures.

Bumps the CLI version to 1.1.65, updates @socketsecurity/sdk to 1.4.96, and adds a CHANGELOG.md entry for the release.

Written by Cursor Bugbot for commit 52f0463. This will update automatically on new commits. Configure here.

Surface the failing endpoint URL in API error messages so users can
quickly identify which request failed. Uses the new `url` field from
@socketsecurity/sdk 1.4.96 for SDK-routed calls and appends the path
for direct-fetch calls in queryApiSafeText and sendApiRequest.
@mtorp mtorp requested a review from jdalton February 26, 2026 11:44
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​socketsecurity/​sdk@​1.4.95 ⏵ 1.4.96100100100100100

View full report

@socket-security-staging
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​socketsecurity/​sdk@​1.4.95 ⏵ 1.4.96100100100100100

View full report

@jdalton jdalton merged commit e17a510 into v1.x Feb 26, 2026
8 of 11 checks passed
@jdalton jdalton deleted the add-url-to-api-errors branch February 26, 2026 13:28
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.

2 participants