11import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
2+ import { debugFn } from '@socketsecurity/registry/lib/debug'
3+ import { logger } from '@socketsecurity/registry/lib/logger'
24
35import { extractPurlsFromPnpmLockfile } from './pnpm.mts'
46import { getPublicToken , setupSdk } from './sdk.mts'
57import { addArtifactToAlertsMap } from './socket-package-alert.mts'
8+ import constants from '../constants.mts'
69
710import type { CompactSocketArtifact } from './alert/artifact.mts'
811import type {
@@ -12,6 +15,7 @@ import type {
1215import type { LockfileObject } from '@pnpm/lockfile.fs'
1316import type { Spinner } from '@socketsecurity/registry/lib/spinner'
1417
18+
1519export 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