Skip to content

Commit bb75194

Browse files
committed
Fix fix command when server rejects request
1 parent c787748 commit bb75194

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/utils/alerts-map.mts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
2+
import { debugFn } from '@socketsecurity/registry/lib/debug'
3+
import { logger } from '@socketsecurity/registry/lib/logger'
24

35
import { extractPurlsFromPnpmLockfile } from './pnpm.mts'
46
import { getPublicToken, setupSdk } from './sdk.mts'
57
import { addArtifactToAlertsMap } from './socket-package-alert.mts'
8+
import constants from '../constants.mts'
69

710
import type { CompactSocketArtifact } from './alert/artifact.mts'
811
import type {
@@ -12,6 +15,7 @@ import type {
1215
import type { LockfileObject } from '@pnpm/lockfile.fs'
1316
import type { Spinner } from '@socketsecurity/registry/lib/spinner'
1417

18+
1519
export type GetAlertsMapFromPnpmLockfileOptions = {
1620
consolidate?: boolean | undefined
1721
include?: AlertIncludeFilter | undefined
@@ -117,6 +121,19 @@ export async function getAlertsMapFromPurls(
117121
throw new Error(
118122
`Socket API server error (${statusCode}): ${statusMessage}`,
119123
)
124+
} else {
125+
if (batchResult.status >= 300 && batchResult.status !== 400) {
126+
const { spinner } = constants
127+
spinner.stop()
128+
debugFn('Received a result=false:', batchResult)
129+
logger.fail(
130+
`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`,
131+
batchResult.error,
132+
batchResult.cause ? `( ${batchResult.cause} )` : '',
133+
)
134+
break
135+
}
136+
debugFn('Received a result=false:', batchResult)
120137
}
121138
remaining -= 1
122139
if (spinner && remaining > 0) {

0 commit comments

Comments
 (0)