Skip to content

Commit

Permalink
fix(github): don't crash if a user that is listed as collaborator doe…
Browse files Browse the repository at this point in the history
…s not exist
  • Loading branch information
tagoro9 committed Feb 13, 2023
1 parent 46ff7b5 commit c85ee52
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/git/Github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
compose,
concat as rConcat,
filter,
has,
head,
join,
map,
Expand Down Expand Up @@ -247,7 +246,10 @@ export class Github implements Remote {
map<RestEndpointMethodTypes['users']['getByUsername']['response']['data'], Reviewer>(
(user) => user as Reviewer,
),
filter(has('login')),
filter(
(data: RestEndpointMethodTypes['users']['getByUsername']['response']['data']) =>
data !== undefined && 'login' in data,
),
),
);
}
Expand Down Expand Up @@ -300,9 +302,18 @@ export class Github implements Remote {
})
private getUserInfo(
username: string,
): Promise<RestEndpointMethodTypes['users']['getByUsername']['response']['data']> {
): Promise<RestEndpointMethodTypes['users']['getByUsername']['response']['data'] | undefined> {
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,
);
Expand Down

0 comments on commit c85ee52

Please sign in to comment.