From d20c7f86277d16b4f173eebc9ee9a1dc8fbaa1d1 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Fri, 29 May 2026 16:04:16 +0200 Subject: [PATCH] fix: handle 404 gracefully when a governance team does not exist --- dist/index.js | 13 +++++++++++-- src/bot.ts | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7181be2..5311eae 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8939,8 +8939,17 @@ function getCommandsFromComment(body) { exports.getCommandsFromComment = getCommandsFromComment; function inTeam(org, username, team) { return __awaiter(this, void 0, void 0, function* () { - const members = yield octokit_1.default.teams.listMembersInOrg({ org, team_slug: team }); - return members.data.map(m => m.login).includes(username); + try { + const members = yield octokit_1.default.teams.listMembersInOrg({ org, team_slug: team }); + return members.data.map(m => m.login).includes(username); + } + catch (e) { + if (e.status === 404) { + console.warn(`404 while fetching members of '${team}' team`); + return false; + } + throw e; + } }); } exports.inTeam = inTeam; diff --git a/src/bot.ts b/src/bot.ts index 9df106d..001d24c 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -39,9 +39,18 @@ export function getCommandsFromComment(body: string): Command[] { } export async function inTeam(org: string, username: string, team: string) { - const members = await octokit.teams.listMembersInOrg({ org, team_slug: team }); + try { + const members = await octokit.teams.listMembersInOrg({ org, team_slug: team }); + + return members.data.map(m => m.login).includes(username); + } catch (e) { + if ((e as RequestError).status === 404) { + console.warn(`404 while fetching members of '${team}' team`); + return false; + } - return members.data.map(m => m.login).includes(username); + throw e; + } } export async function isMaintainer(org: string, username: string) {