From baa007a3ec47207fe5de4e2848b20374a2eba832 Mon Sep 17 00:00:00 2001 From: Vlad Mocanu Date: Thu, 26 Feb 2026 10:25:50 +0200 Subject: [PATCH] fix: normalize Forgejo 'label_updated' to 'labeled' in context Forgejo sends eventAction 'label_updated' instead of 'labeled' for issue label events. Add FORGEJO_EVENT_ACTION_MAP in context.ts to normalize at parse time (same pattern as event name normalization), so all downstream code (trigger.ts, create-prompt) works unchanged. Co-Authored-By: Claude Opus 4.6 --- src/github/context.ts | 15 ++++++++++++++- src/github/validation/trigger.ts | 7 +------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/github/context.ts b/src/github/context.ts index 07b0df0..4ea84f9 100644 --- a/src/github/context.ts +++ b/src/github/context.ts @@ -68,10 +68,23 @@ const FORGEJO_EVENT_NAME_MAP: Record = { pull_request_comment: "pull_request_review_comment", }; +/** + * Forgejo uses different action names for some webhook event actions. + * Normalize to GitHub-canonical names so all downstream code works unchanged. + */ +const FORGEJO_EVENT_ACTION_MAP: Record = { + label_updated: "labeled", +}; + function normalizeEventName(eventName: string): string { return FORGEJO_EVENT_NAME_MAP[eventName] ?? eventName; } +function normalizeEventAction(action: string | undefined): string | undefined { + if (!action) return action; + return FORGEJO_EVENT_ACTION_MAP[action] ?? action; +} + const AUTOMATION_EVENT_NAMES = [ "workflow_dispatch", "repository_dispatch", @@ -149,7 +162,7 @@ export function parseGitHubContext(): GitHubContext { const commonFields = { runId: process.env.GITHUB_RUN_ID!, - eventAction: context.payload.action, + eventAction: normalizeEventAction(context.payload.action), repository: { owner: context.repo.owner, repo: context.repo.repo, diff --git a/src/github/validation/trigger.ts b/src/github/validation/trigger.ts index f8b3685..c16cdf1 100644 --- a/src/github/validation/trigger.ts +++ b/src/github/validation/trigger.ts @@ -36,12 +36,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean { } // Check for label trigger - // Forgejo sends "label_updated" instead of "labeled" for issue label events - if ( - isIssuesEvent(context) && - (context.eventAction === "labeled" || - context.eventAction === "label_updated") - ) { + if (isIssuesEvent(context) && context.eventAction === "labeled") { const labelName = (context.payload as any).label?.name || ""; if (labelTrigger && labelName === labelTrigger) {