From f2d59dfa4b94fb47bd062cda10e900265fbf22bb Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Thu, 23 May 2024 20:49:47 +0900 Subject: [PATCH 1/2] fix: the bot doesn't crash on permit generation when the closer of the issue is not a member --- src/helpers/issue.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/helpers/issue.ts b/src/helpers/issue.ts index 674a7c547..53ad8baaf 100644 --- a/src/helpers/issue.ts +++ b/src/helpers/issue.ts @@ -163,16 +163,17 @@ export async function isUserAdminOrBillingManager( async function checkIfIsBillingManager() { if (!payload.organization) throw context.logger.fatal(`No organization found in payload!`); - const { data: membership } = await context.octokit.rest.orgs.getMembershipForUser({ - org: payload.organization.login, - username: payload.repository.owner.login, - }); - - console.trace(membership); - if (membership.role === "billing_manager") { - return true; - } else { - return false; + try { + const { data: membership } = await context.octokit.rest.orgs.getMembershipForUser({ + org: payload.organization.login, + username: payload.repository.owner.login, + }); + + console.trace(membership); + return membership.role === "billing_manager"; + } catch (e) { + context.logger.error("Could not get the Billing Manager from membership", e) + return false } } } From ceb6d6e204c3f0218302b4501a995f5b500358a3 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Thu, 23 May 2024 20:52:25 +0900 Subject: [PATCH 2/2] chore: improved debug message --- src/helpers/issue.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helpers/issue.ts b/src/helpers/issue.ts index 53ad8baaf..024a9d8b4 100644 --- a/src/helpers/issue.ts +++ b/src/helpers/issue.ts @@ -172,8 +172,11 @@ export async function isUserAdminOrBillingManager( console.trace(membership); return membership.role === "billing_manager"; } catch (e) { - context.logger.error("Could not get the Billing Manager from membership", e) - return false + context.logger.error( + `Could not get the Billing Manager status for ${payload.repository.owner.login} within ${payload.organization.login}`, + e + ); + return false; } } }