1
1
import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
2
+ import { debugFn } from '@socketsecurity/registry/lib/debug'
3
+ import { logger } from '@socketsecurity/registry/lib/logger'
2
4
3
5
import { extractPurlsFromPnpmLockfile } from './pnpm.mts'
4
6
import { getPublicToken , setupSdk } from './sdk.mts'
5
7
import { addArtifactToAlertsMap } from './socket-package-alert.mts'
8
+ import constants from '../constants.mts'
6
9
7
10
import type { CompactSocketArtifact } from './alert/artifact.mts'
8
11
import type {
@@ -12,6 +15,7 @@ import type {
12
15
import type { LockfileObject } from '@pnpm/lockfile.fs'
13
16
import type { Spinner } from '@socketsecurity/registry/lib/spinner'
14
17
18
+
15
19
export type GetAlertsMapFromPnpmLockfileOptions = {
16
20
consolidate ?: boolean | undefined
17
21
include ?: AlertIncludeFilter | undefined
@@ -117,6 +121,19 @@ export async function getAlertsMapFromPurls(
117
121
throw new Error (
118
122
`Socket API server error (${ statusCode } ): ${ statusMessage } ` ,
119
123
)
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 )
120
137
}
121
138
remaining -= 1
122
139
if ( spinner && remaining > 0 ) {
0 commit comments