@@ -44,8 +44,15 @@ export async function getOSPSBaselineInsights(repoUrl: string, token: string): P
4444
4545 const combinedOutput = `${ stdout } \n${ stderr } `
4646
47+ if ( combinedOutput . includes ( '401 Unauthorized' ) ) {
48+ svc . log . warn ( 'Detected 401 error in privateer output - token invalid or expired!' )
49+ throw ApplicationFailure . create ( {
50+ message : 'GitHub token invalid or expired' ,
51+ type : 'Token403Error' ,
52+ } )
53+ }
4754 if ( combinedOutput . includes ( '403' ) ) {
48- svc . log . warn ( 'Detected 403 error in privateer output!' )
55+ svc . log . warn ( 'Detected 403 error in privateer output - token rate-limited !' )
4956 throw ApplicationFailure . create ( {
5057 message : 'GitHub token rate-limited' ,
5158 type : 'Token403Error' ,
@@ -54,10 +61,17 @@ export async function getOSPSBaselineInsights(repoUrl: string, token: string): P
5461 } catch ( err ) {
5562 svc . log . error ( `Privateer run failed: ${ err . message } ` )
5663
57- // check for 403 in captured output if available
64+ // check for auth errors in captured output if available
5865 const output = `${ err . stdout || '' } \n${ err . stderr || '' } `
66+ if ( output . includes ( '401 Unauthorized' ) ) {
67+ svc . log . warn ( 'Detected 401 error in failed privateer output - token invalid or expired!' )
68+ throw ApplicationFailure . create ( {
69+ message : 'GitHub token invalid or expired' ,
70+ type : 'Token403Error' ,
71+ } )
72+ }
5973 if ( output . includes ( '403' ) ) {
60- svc . log . warn ( 'Detected 403 error in failed privateer output!' )
74+ svc . log . warn ( 'Detected 403 error in failed privateer output - token rate-limited !' )
6175 throw ApplicationFailure . create ( {
6276 message : 'GitHub token rate-limited' ,
6377 type : 'Token403Error' ,
0 commit comments