1- // @ts -nocheck - Type checking disabled due to complex type errors requiring refactoring
1+ // @ts -check
22/// <reference types="@actions/github-script" />
33
44/**
@@ -59,7 +59,8 @@ async function getAvailableAgentLogins(owner, repo) {
5959 const available = actors . filter ( actor => actor ?. login && knownValues . includes ( actor . login ) ) . map ( actor => actor . login ) ;
6060 return available . sort ( ) ;
6161 } catch ( e ) {
62- core . debug ( `Failed to list available agent logins: ${ e ?. message ?? String ( e ) } ` ) ;
62+ const errorMessage = e instanceof Error ? e . message : String ( e ) ;
63+ core . debug ( `Failed to list available agent logins: ${ errorMessage } ` ) ;
6364 return [ ] ;
6465 }
6566}
@@ -117,7 +118,8 @@ async function findAgent(owner, repo, agentName) {
117118 }
118119 return null ;
119120 } catch ( error ) {
120- core . error ( `Failed to find ${ agentName } agent: ${ error ?. message ?? String ( error ) } ` ) ;
121+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
122+ core . error ( `Failed to find ${ agentName } agent: ${ errorMessage } ` ) ;
121123 return null ;
122124 }
123125}
@@ -161,7 +163,8 @@ async function getIssueDetails(owner, repo, issueNumber) {
161163 currentAssignees,
162164 } ;
163165 } catch ( error ) {
164- core . error ( `Failed to get issue details: ${ error ?. message ?? String ( error ) } ` ) ;
166+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
167+ core . error ( `Failed to get issue details: ${ errorMessage } ` ) ;
165168 return null ;
166169 }
167170}
@@ -204,21 +207,22 @@ async function assignAgentToIssue(issueId, agentId, currentAssignees, agentName)
204207 core . error ( "Unexpected response from GitHub API" ) ;
205208 return false ;
206209 } catch ( error ) {
207- const errorMessage = error ? .message ?? String ( error ) ;
210+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
208211
209212 // Debug: surface the raw GraphQL error structure for troubleshooting fine-grained permission issues
210213 try {
211214 core . debug ( `Raw GraphQL error message: ${ errorMessage } ` ) ;
212215 if ( error && typeof error === "object" ) {
213216 // Common GraphQL error shapes: error.errors (array), error.data, error.response
217+ const err = /** @type {any } */ ( error ) ;
214218 const details = {
215- ...( error . errors && { errors : error . errors } ) ,
216- ...( error . response && { response : error . response } ) ,
217- ...( error . data && { data : error . data } ) ,
219+ ...( err . errors && { errors : err . errors } ) ,
220+ ...( err . response && { response : err . response } ) ,
221+ ...( err . data && { data : err . data } ) ,
218222 } ;
219223 // If GitHub returns an array of errors with 'type'/'message'
220- if ( Array . isArray ( error . errors ) ) {
221- details . compactMessages = error . errors . map ( e => e . message ) . filter ( Boolean ) ;
224+ if ( Array . isArray ( err . errors ) ) {
225+ details . compactMessages = err . errors . map ( e => e . message ) . filter ( Boolean ) ;
222226 }
223227 const serialized = JSON . stringify ( details , null , 2 ) ;
224228 if ( serialized !== "{}" ) {
@@ -233,7 +237,8 @@ async function assignAgentToIssue(issueId, agentId, currentAssignees, agentName)
233237 }
234238 } catch ( loggingErr ) {
235239 // Never fail assignment because of debug logging
236- core . debug ( `Failed to serialize GraphQL error details: ${ loggingErr ?. message ?? String ( loggingErr ) } ` ) ;
240+ const loggingErrMsg = loggingErr instanceof Error ? loggingErr . message : String ( loggingErr ) ;
241+ core . debug ( `Failed to serialize GraphQL error details: ${ loggingErrMsg } ` ) ;
237242 }
238243
239244 // Check for permission-related errors
@@ -263,7 +268,8 @@ async function assignAgentToIssue(issueId, agentId, currentAssignees, agentName)
263268 }
264269 core . warning ( "Fallback mutation returned unexpected response; proceeding with permission guidance." ) ;
265270 } catch ( fallbackError ) {
266- core . error ( `Fallback addAssigneesToAssignable failed: ${ fallbackError ?. message ?? String ( fallbackError ) } ` ) ;
271+ const fallbackErrMsg = fallbackError instanceof Error ? fallbackError . message : String ( fallbackError ) ;
272+ core . error ( `Fallback addAssigneesToAssignable failed: ${ fallbackErrMsg } ` ) ;
267273 }
268274 logPermissionError ( agentName ) ;
269275 } else {
@@ -392,7 +398,8 @@ async function assignAgentToIssueByName(owner, repo, issueNumber, agentName) {
392398 core . info ( `Successfully assigned ${ agentName } coding agent to issue #${ issueNumber } ` ) ;
393399 return { success : true } ;
394400 } catch ( error ) {
395- return { success : false , error : error ?. message ?? String ( error ) } ;
401+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
402+ return { success : false , error : errorMessage } ;
396403 }
397404}
398405
0 commit comments