From 9b37967cd7527f8853f6baa6c763c58f48240e4b Mon Sep 17 00:00:00 2001 From: koya0 Date: Tue, 14 Jan 2025 19:26:34 -0300 Subject: [PATCH] fix: validate presence of price label in issue before checking requirements --- src/handlers/shared/start.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/handlers/shared/start.ts b/src/handlers/shared/start.ts index 6b21a0b3..b2b0772a 100644 --- a/src/handlers/shared/start.ts +++ b/src/handlers/shared/start.ts @@ -67,6 +67,13 @@ export async function start( throw logger.error(`Skipping '/start' since there is no sender in the context.`); } + const labels = issue.labels ?? []; + const priceLabel = labels.find((label: Label) => label.name.startsWith("Price: ")); + + if (!priceLabel) { + throw logger.error("No price label is set to calculate the duration", { issueNumber: issue.number }); + } + await checkRequirements(context, issue, sender.login); // is it a child issue? @@ -158,13 +165,6 @@ ${issues} return { content: error, status: HttpStatusCode.NOT_MODIFIED }; } - const labels = issue.labels ?? []; - const priceLabel = labels.find((label: Label) => label.name.startsWith("Price: ")); - - if (!priceLabel) { - throw logger.error("No price label is set to calculate the duration", { issueNumber: issue.number }); - } - // Checks if non-collaborators can be assigned to the issue for (const label of labels) { if (label.description?.toLowerCase().includes("collaborator only")) {