From 0b2c0bad6a824cf622aa152c4876d631dddef131 Mon Sep 17 00:00:00 2001 From: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> Date: Sun, 18 Aug 2024 19:30:39 +0900 Subject: [PATCH] chore: throw error if no owner is set --- src/helpers/github.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/helpers/github.ts b/src/helpers/github.ts index c079e95f..4a1aac94 100644 --- a/src/helpers/github.ts +++ b/src/helpers/github.ts @@ -104,8 +104,13 @@ export async function isCiGreen({ octokit, logger, env }: Context, sha: string, } } -function parseTarget({ payload }: Context, target: string) { - const owner = payload.repository.owner?.login || ""; +function parseTarget({ payload, logger }: Context, target: string) { + if (!payload.repository.owner) { + const errorMessage = "No repository owner has been found, the target cannot be parsed."; + logger.error(errorMessage); + throw new Error(errorMessage); + } + const owner = payload.repository.owner.login; const [orgParsed, repoParsed] = target.split("/"); let repoTarget = null; if (orgParsed !== owner) {