Skip to content

Commit e8a1a50

Browse files
🐛 handle user add errors (#90)
* While checks should have occured beforehand for if a user is real or not, current caching strategies cause the checks to sometimes return false positives.
1 parent 2e23f89 commit e8a1a50

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

src/services/gitHub.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AppConfig } from "./appConfig";
66
import yaml from "js-yaml";
77
import { throttling } from "@octokit/plugin-throttling";
88
import { AsyncReturnType } from "../utility";
9-
import { Log, LoggerToUse } from "../logging";
9+
import { Log, LogError, LoggerToUse } from "../logging";
1010
import { GitHubClientCache } from "./gitHubCache";
1111
import { redisClient } from "../app";
1212
import { GitHubTeamName, OrgConfig, OrgConfigurationOptions } from "./orgConfig";
@@ -377,19 +377,28 @@ class InstalledGitHubClient implements InstalledClient {
377377
}
378378

379379
public async AddOrgMember(id: string): Response<boolean> {
380-
const response = await this.gitHubClient.rest.orgs.setMembershipForUser({
381-
org: this.orgName,
382-
username: id
383-
})
384-
385-
if (response.status != 200) {
380+
try {
381+
const response = await this.gitHubClient.rest.orgs.setMembershipForUser({
382+
org: this.orgName,
383+
username: id
384+
})
385+
386+
if (response.status != 200) {
387+
return {
388+
successful: false
389+
}
390+
}
391+
386392
return {
387393
successful: false
388394
}
389395
}
396+
catch (e) {
397+
LogError(`Error adding Org Member ${id}: ${JSON.stringify(e)}`)
390398

391-
return {
392-
successful: false
399+
return {
400+
successful: false
401+
}
393402
}
394403
}
395404

0 commit comments

Comments
 (0)