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({