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 <noreply@anthropic.com>
This commit is contained in:
1 parent
910c843122
commit
ac8e22e2f8
1 file changed
+20
-11
@@ -66,19 +66,28 @@ export async function updateCommentLink(
|
|||||||
// GitHub has separate ID namespaces for review comments and issue comments
|
// GitHub has separate ID namespaces for review comments and issue comments
|
||||||
// We need to use the correct API based on the event type
|
// We need to use the correct API based on the event type
|
||||||
if (isPullRequestReviewCommentEvent(context)) {
|
if (isPullRequestReviewCommentEvent(context)) {
|
||||||
// For PR review comments, use the pulls API
|
// For PR review comments, try the pulls API first.
|
||||||
console.log(`Fetching PR review comment ${commentId}`);
|
// On Forgejo, the initial comment may have been created as a regular
|
||||||
const { data: prComment } = await octokit.rest.pulls.getReviewComment({
|
// issue comment (because the payload lacks comment.id), so the pulls
|
||||||
owner,
|
// endpoint may 404. Fall through to issue comment fetch in that case.
|
||||||
repo,
|
try {
|
||||||
comment_id: commentId,
|
console.log(`Fetching PR review comment ${commentId}`);
|
||||||
});
|
const { data: prComment } = await octokit.rest.pulls.getReviewComment({
|
||||||
comment = prComment;
|
owner,
|
||||||
isPRReviewComment = true;
|
repo,
|
||||||
console.log("Successfully fetched as PR review comment");
|
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) {
|
if (!comment) {
|
||||||
console.log(`Fetching issue comment ${commentId}`);
|
console.log(`Fetching issue comment ${commentId}`);
|
||||||
const { data: issueComment } = await octokit.rest.issues.getComment({
|
const { data: issueComment } = await octokit.rest.issues.getComment({
|
||||||
|
|||||||
Reference in new issue
Block a user