diff --git a/services/github/pod-github/src/sync/issues.ts b/services/github/pod-github/src/sync/issues.ts index 200b74c4458..074640f68ef 100644 --- a/services/github/pod-github/src/sync/issues.ts +++ b/services/github/pod-github/src/sync/issues.ts @@ -939,7 +939,9 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan break } const docsPart = allSyncDocs.splice(0, partsize) - const idsPart = docsPart.map((it) => (it.external as IssueExternalData).id).filter((it) => it !== undefined) + const idsPart = docsPart + .map((it) => (it.external as IssueExternalData | undefined)?.id) + .filter((id): id is string => id !== undefined) if (idsPart.length === 0) { break } @@ -986,7 +988,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan }) } else if (partsize === 1) { // We need to update issue, since it is missing on external side. - const syncDoc = syncDocs.find((it) => it.external.id === idsPart[0]) + const syncDoc = syncDocs.find((it) => it.external?.id === idsPart[0]) if (syncDoc !== undefined) { ctx.warn('mark missing external PR', { errors: err.errors, @@ -1008,7 +1010,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan } } for (const d of syncDocs) { - if ((d.external as IssueExternalData).id == null) { + if ((d.external as IssueExternalData)?.id == null) { ctx.error('failed to do external sync for', { objectClass: d.objectClass, _id: d._id }) // no external data for doc await derivedClient.update(d, { diff --git a/services/github/pod-github/src/sync/pullrequests.ts b/services/github/pod-github/src/sync/pullrequests.ts index 97df74b3f1b..0d574222057 100644 --- a/services/github/pod-github/src/sync/pullrequests.ts +++ b/services/github/pod-github/src/sync/pullrequests.ts @@ -1319,7 +1319,9 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS try { while (true) { const docsPart = allSyncDocs.splice(0, partsize) - const idsPart = docsPart.map((it) => (it.external as IssueExternalData).id).filter((it) => it !== undefined) + const idsPart = docsPart + .map((it) => (it.external as IssueExternalData | undefined)?.id) + .filter((id): id is string => id !== undefined) if (idsPart.length === 0) { break } @@ -1366,7 +1368,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS }) } else if (partsize === 1) { // We need to update issue, since it is missing on external side. - const syncDoc = syncDocs.find((it) => it.external.id === idsPart[0]) + const syncDoc = syncDocs.find((it) => it.external?.id === idsPart[0]) if (syncDoc !== undefined) { ctx.warn('mark missing external PR', { errors: err.errors, @@ -1388,7 +1390,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS } } for (const d of syncDocs) { - if ((d.external as IssueExternalData).id == null) { + if ((d.external as IssueExternalData | undefined)?.id == null) { ctx.error('failed to do external sync for', { objectClass: d.objectClass, _id: d._id }) // no external data for doc await derivedClient.update(d, {