Skip to content

Commit

Permalink
Fix: Github Discussion comment author can be null (#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipperolet authored Nov 10, 2023
1 parent 66a57e2 commit dcd4959
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions connectors/src/connectors/github/lib/github_graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
8 changes: 6 additions & 2 deletions connectors/src/connectors/github/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand All @@ -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) {
Expand Down

0 comments on commit dcd4959

Please sign in to comment.