From c85ee52b286c5c2d8c2d31c58031c9a0be915f86 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 13 Feb 2023 20:06:17 +0000 Subject: [PATCH] fix(github): don't crash if a user that is listed as collaborator does not exist --- src/git/Github.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/git/Github.ts b/src/git/Github.ts index 157cebc2..79b9871d 100644 --- a/src/git/Github.ts +++ b/src/git/Github.ts @@ -6,7 +6,6 @@ import { compose, concat as rConcat, filter, - has, head, join, map, @@ -247,7 +246,10 @@ export class Github implements Remote { map( (user) => user as Reviewer, ), - filter(has('login')), + filter( + (data: RestEndpointMethodTypes['users']['getByUsername']['response']['data']) => + data !== undefined && 'login' in data, + ), ), ); } @@ -300,9 +302,18 @@ export class Github implements Remote { }) private getUserInfo( username: string, - ): Promise { + ): Promise { return this.queueCall( - () => this.api.users.getByUsername({ username }).then(prop('data')), + () => + this.api.users + .getByUsername({ username }) + .then(prop('data')) + .catch((error) => { + if (error.status !== 404) { + throw error; + } + return undefined; + }), `Getting user info for %s`, username, );