From dcd4959535289eabcf19005a33b3c897a204c655 Mon Sep 17 00:00:00 2001 From: Philippe Rolet Date: Fri, 10 Nov 2023 10:43:39 +0100 Subject: [PATCH] Fix: Github Discussion comment author can be null (#2477) Related [discussion](https://dust4ai.slack.com/archives/C05F84CFP0E/p1699564850972439) --- connectors/src/connectors/github/lib/github_graphql.ts | 9 ++++++--- connectors/src/connectors/github/temporal/activities.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/connectors/src/connectors/github/lib/github_graphql.ts b/connectors/src/connectors/github/lib/github_graphql.ts index 7f259ca9141f..4ddd11e34faa 100644 --- a/connectors/src/connectors/github/lib/github_graphql.ts +++ b/connectors/src/connectors/github/lib/github_graphql.ts @@ -34,9 +34,12 @@ const DiscussionCommentNodeSchema = t.type({ bodyText: t.string, createdAt: t.string, updatedAt: t.string, - author: t.type({ - login: t.string, - }), + author: t.union([ + t.type({ + login: t.string, + }), + t.null, + ]), }); export type DiscussionCommentNode = t.TypeOf< diff --git a/connectors/src/connectors/github/temporal/activities.ts b/connectors/src/connectors/github/temporal/activities.ts index e2dce93b4985..7e9f346b7597 100644 --- a/connectors/src/connectors/github/temporal/activities.ts +++ b/connectors/src/connectors/github/temporal/activities.ts @@ -235,7 +235,9 @@ export async function githubUpsertDiscussionActivity( if (comment.isAnswer) { renderedDiscussion += "[ACCEPTED ANSWER] "; } - renderedDiscussion += `${comment.author.login}: ${comment.bodyText}||`; + renderedDiscussion += `${comment.author?.login || "Unknown author"}: ${ + comment.bodyText + }||`; let nextChildCursor: string | null = null; for (;;) { const { cursor: childCursor, comments: childComments } = @@ -245,7 +247,9 @@ export async function githubUpsertDiscussionActivity( nextChildCursor ); for (const childComment of childComments) { - renderedDiscussion += `----${childComment.author.login}: ${childComment.bodyText}||`; + renderedDiscussion += `----${ + childComment.author?.login || "Unknown author" + }: ${childComment.bodyText}||`; } if (!childCursor) {