diff --git a/src/create-prompt/index.ts b/src/create-prompt/index.ts index d9f99cd..a257833 100644 --- a/src/create-prompt/index.ts +++ b/src/create-prompt/index.ts @@ -142,9 +142,13 @@ export function prepareContext( commentBody = context.payload.review.body ?? ""; triggerUsername = context.payload.review.user.login; } else if (isPullRequestReviewCommentEvent(context)) { - commentId = context.payload.comment.id.toString(); - commentBody = context.payload.comment.body; - triggerUsername = context.payload.comment.user.login; + // Forgejo's pull_request_review_comment payload may not include a + // top-level `comment` object. Use optional chaining and fall back + // to actor/empty values — the data fetcher provides the full data. + commentId = (context.payload as any).comment?.id?.toString(); + commentBody = (context.payload as any).comment?.body ?? ""; + triggerUsername = + (context.payload as any).comment?.user?.login ?? context.actor; } else if (isIssuesEvent(context)) { triggerUsername = context.payload.issue.user.login; } diff --git a/src/github/validation/trigger.ts b/src/github/validation/trigger.ts index 74b385d..c16cdf1 100644 --- a/src/github/validation/trigger.ts +++ b/src/github/validation/trigger.ts @@ -10,6 +10,7 @@ import { isPullRequestReviewCommentEvent, } from "../context"; import type { ParsedGitHubContext } from "../context"; +import { detectPlatform } from "../../platform/detector"; export function checkContainsTrigger(context: ParsedGitHubContext): boolean { const { @@ -119,6 +120,21 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean { isIssueCommentEvent(context) || isPullRequestReviewCommentEvent(context) ) { + // Forgejo's pull_request_review_comment payload does NOT include a + // top-level `comment` object (it's undefined). On Forgejo, the + // workflow `if:` already gates on event name alone, so always trigger + // here — the actual comment data is fetched via REST in the data + // fetcher, and non-matching comments won't produce useful output. + if ( + isPullRequestReviewCommentEvent(context) && + detectPlatform() === "forgejo" + ) { + console.log( + "Forgejo pull_request_review_comment: triggering (payload lacks comment body)", + ); + return true; + } + const commentBody = isIssueCommentEvent(context) ? context.payload.comment.body : context.payload.comment.body;