From ac8e22e2f8279bc1f479a5add1bc6e7a0e9c4532 Mon Sep 17 00:00:00 2001 From: Vlad Mocanu Date: Thu, 26 Feb 2026 08:49:19 +0200 Subject: [PATCH] fix: fall through to issue comment when PR review comment fetch 404s On Forgejo, pull_request_review_comment events create the tracking comment as a regular issue comment (because the payload lacks comment.id for reply-to-review). The update-comment-link step then tried pulls.getReviewComment() first, which 404'd and threw before reaching the issues.getComment() fallback. Wrap the PR review comment fetch in its own try/catch so it falls through to the issue comment fetch on failure. Co-Authored-By: Claude Opus 4.6 --- src/entrypoints/update-comment-link.ts | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/entrypoints/update-comment-link.ts b/src/entrypoints/update-comment-link.ts index 40f1c54..ec94b3b 100644 --- a/src/entrypoints/update-comment-link.ts +++ b/src/entrypoints/update-comment-link.ts @@ -66,19 +66,28 @@ export async function updateCommentLink( // GitHub has separate ID namespaces for review comments and issue comments // We need to use the correct API based on the event type if (isPullRequestReviewCommentEvent(context)) { - // For PR review comments, use the pulls API - console.log(`Fetching PR review comment ${commentId}`); - const { data: prComment } = await octokit.rest.pulls.getReviewComment({ - owner, - repo, - comment_id: commentId, - }); - comment = prComment; - isPRReviewComment = true; - console.log("Successfully fetched as PR review comment"); + // For PR review comments, try the pulls API first. + // On Forgejo, the initial comment may have been created as a regular + // issue comment (because the payload lacks comment.id), so the pulls + // endpoint may 404. Fall through to issue comment fetch in that case. + try { + console.log(`Fetching PR review comment ${commentId}`); + const { data: prComment } = await octokit.rest.pulls.getReviewComment({ + owner, + repo, + comment_id: commentId, + }); + comment = prComment; + isPRReviewComment = true; + console.log("Successfully fetched as PR review comment"); + } catch { + console.log( + `Comment ${commentId} not found as PR review comment, trying issue comment`, + ); + } } - // For all other event types, use the issues API + // For all other event types, or if the PR review comment fetch failed if (!comment) { console.log(`Fetching issue comment ${commentId}`); const { data: issueComment } = await octokit.rest.issues.getComment({