feat: include request URL in API error messages#1094
Merged
Conversation
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.
|
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.
|
jdalton
approved these changes
Feb 26, 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.
Problem
When a Socket API request fails, the CLI displays an error like:
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 newurlfield fromSocketSdkErrorResult(added in@socketsecurity/sdk1.4.96, SocketDev/socket-sdk-js#483) and append it to the cause string.Direct-fetch calls (
queryApiSafeText,sendApiRequest): Append the requestpathto all error cause strings — the catch block, the!result.okbranch, and the response parsing error.Example output after this change
Changes
src/utils/api.mts: UpdatedhandleApiCall,handleApiCallNoSpinner,queryApiSafeText, andsendApiRequestto include URL/path in error messagespackage.json: Bumped@socketsecurity/sdkto1.4.96, version to1.1.65CHANGELOG.md: Added entry for1.1.65Test plan
pnpm build:dist:src)pnpm check:tsc)pnpm check:lint)socket scan create --org nonexistent-org— URL appears in error outputNote
Low Risk
Low risk: changes are limited to error-message formatting and a minor
@socketsecurity/sdkpatch bump; main potential impact is downstream tests/log parsing expecting the oldcausestrings.Overview
Improves CLI debuggability by appending the failing endpoint to all Socket API error causes: SDK-routed failures now include
errCResult.url, and directfetchhelpers (queryApiSafeText,sendApiRequest) always include the requestpathin catch, non-OK response, and parse/read failures.Bumps the CLI version to
1.1.65, updates@socketsecurity/sdkto1.4.96, and adds aCHANGELOG.mdentry for the release.Written by Cursor Bugbot for commit 52f0463. This will update automatically on new commits. Configure here.