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
+11
-2
@@ -66,7 +66,11 @@ 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.
|
||||||
|
// 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}`);
|
console.log(`Fetching PR review comment ${commentId}`);
|
||||||
const { data: prComment } = await octokit.rest.pulls.getReviewComment({
|
const { data: prComment } = await octokit.rest.pulls.getReviewComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -76,9 +80,14 @@ export async function updateCommentLink(
|
|||||||
comment = prComment;
|
comment = prComment;
|
||||||
isPRReviewComment = true;
|
isPRReviewComment = true;
|
||||||
console.log("Successfully fetched as PR review comment");
|
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