@@ -57,8 +57,8 @@ export async function restoreGithubIntegrations (dbUrl: string, dryrun: boolean)
57
57
const allInstallationIds = new Set < number > ( )
58
58
if ( existingInstallationId != null ) {
59
59
if ( Array . isArray ( existingInstallationId ) ) {
60
- existingInstallationId . forEach ( ( id ) => allInstallationIds . add ( id ) )
61
- } else {
60
+ existingInstallationId . filter ( isValidInstallationId ) . forEach ( ( id ) => allInstallationIds . add ( id ) )
61
+ } else if ( isValidInstallationId ( existingInstallationId ) ) {
62
62
allInstallationIds . add ( existingInstallationId )
63
63
}
64
64
}
@@ -91,6 +91,7 @@ export async function restoreGithubIntegrations (dbUrl: string, dryrun: boolean)
91
91
}
92
92
if ( dryrun ) {
93
93
console . info ( 'Dry run: would update integration' , existingIntegration , updatedIntegration )
94
+ updatedCount ++
94
95
continue
95
96
}
96
97
await accountClient . updateIntegration ( updatedIntegration )
@@ -107,6 +108,7 @@ export async function restoreGithubIntegrations (dbUrl: string, dryrun: boolean)
107
108
}
108
109
if ( dryrun ) {
109
110
console . info ( 'Dry run: would create integration' , integration )
111
+ createdCount ++
110
112
continue
111
113
}
112
114
await accountClient . createIntegration ( integration )
@@ -148,3 +150,11 @@ function groupIntegrationSettings (
148
150
149
151
return Array . from ( groupedSettings . values ( ) )
150
152
}
153
+
154
+ function isValidInstallationId ( id : any ) : boolean {
155
+ if ( typeof id === 'number' && ! isNaN ( id ) && id > 0 ) {
156
+ return true
157
+ }
158
+ const parsed = parseInt ( String ( id ) , 10 )
159
+ return ! isNaN ( parsed ) && parsed > 0
160
+ }
0 commit comments