Skip to content

Commit

Permalink
fix(issue): handle 404 status in fetch pull request reviews
Browse files Browse the repository at this point in the history
Return an empty array if the error status is 404 while fetching reviews.
  • Loading branch information
gentlementlegen authored and jordan-ae committed Nov 6, 2024
1 parent 018c30f commit 39577e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,12 @@ export async function getAllPullRequestReviews(context: Context, pullNumber: num
per_page: 100,
})
).filter((review) => rolesWithReviewAuthority.includes(review.author_association)) as Review[];
} catch (err: unknown) {
throw new Error(context.logger.error("Fetching all pull request reviews failed!", { error: err as Error }).logMessage.raw);
} catch (err) {
if (err && typeof err === "object" && "status" in err && err.status === 404) {
return [];
} else {
throw new Error(context.logger.error("Fetching all pull request reviews failed!", { error: err as Error }).logMessage.raw);
}
}
}

Expand Down

0 comments on commit 39577e4

Please sign in to comment.