Skip to content

Fix fix command when server rejects request #655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 13, 2025
Merged

Fix fix command when server rejects request #655

merged 5 commits into from
Jun 13, 2025

Conversation

pvdz
Copy link
Collaborator

@pvdz pvdz commented Jun 13, 2025

This requires SocketDev/socket-sdk-js#325

That fix propagates an error response, which is returned as the generator's final (done:true) value. But this value was always ignored.

This PR will pick up the response and even when nothrow is set, when the response is 401 or 404 it will consider it a permanent failure.

(I think it should do this regardless but I'll leave that up to @jdalton to refine)

@pvdz pvdz requested a review from jdalton June 13, 2025 12:48
Signed-off-by: John-David Dalton <jdalton@users.noreply.github.com>
jdalton and others added 2 commits June 13, 2025 09:23
Signed-off-by: John-David Dalton <jdalton@users.noreply.github.com>
@jdalton jdalton merged commit aca5a14 into main Jun 13, 2025
15 checks passed
@jdalton jdalton deleted the fixfix branch June 13, 2025 13:26
@@ -117,6 +120,16 @@ export async function getAlertsMapFromPurls(
throw new Error(
`Socket API server error (${statusCode}): ${statusMessage}`,
)
} else {
const { spinner } = constants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codebase appears to be using a style where semicolons are optional. Since this is consistent with the surrounding code, adding an explicit semicolon here isn't necessary. If there's a specific linting rule or style guide requiring semicolons, consider applying it consistently across the entire codebase rather than to individual lines.

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

@@ -117,6 +120,16 @@ export async function getAlertsMapFromPurls(
throw new Error(
`Socket API server error (${statusCode}): ${statusMessage}`,
)
} else {
const { spinner } = constants
spinner.stop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codebase appears to be using a style where semicolons are optional. Since this is consistent with the surrounding code (which also doesn't use semicolons), adding one here would actually be inconsistent with the project's style. Unless there's a specific linting rule for this project requiring semicolons, this code follows what appears to be the established convention.

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +127 to +131
logger.fail(
`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
batchResult.error,
batchResult.cause ? `( ${batchResult.cause} )` : '',
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a semicolon at the end of the logger.fail statement for consistency. While JavaScript has automatic semicolon insertion, explicitly terminating statements helps maintain code clarity, especially in multi-line function calls.

logger.fail(
  `Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
  batchResult.error,
  batchResult.cause ? `( ${batchResult.cause} )` : '',
);
Suggested change
logger.fail(
`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
batchResult.error,
batchResult.cause ? `( ${batchResult.cause} )` : '',
)
logger.fail(
`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
batchResult.error,
batchResult.cause ? `( ${batchResult.cause} )` : '',
)

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

batchResult.error,
batchResult.cause ? `( ${batchResult.cause} )` : '',
)
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The break statement is missing a semicolon. While JavaScript's automatic semicolon insertion will handle this case correctly, adding an explicit semicolon would maintain consistency with the codebase's style conventions.

Suggested change
break
break;

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

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