fix: handle missing comment payload in Forgejo review comment events
Forgejo's pull_request_review_comment event does not include a top-level `comment` object in the payload (it's undefined), causing a crash: "undefined is not an object (evaluating 'context.payload.comment.body')". - trigger.ts: On Forgejo, always trigger for pull_request_review_comment events since the workflow already gates on event name alone - create-prompt/index.ts: Use optional chaining for comment fields, fall back to actor/empty values (data fetcher provides full data) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
b4bc36810d
commit
a10b0475c0
2 files changed
+23
-3
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user