From 2fd4b94a2bcbe92f3bdb3ee42c4279db926b7b67 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Thu, 24 Jul 2025 16:03:16 -0700 Subject: [PATCH] chore: Add missing error handling to open pr func, update logging (#526) * Apply patch * Apply patch * Apply patch * Apply patch * Apply patch * Apply patch * Apply patch * format * cr * chore: Add missing error handling to open pr func, update logging --------- Co-authored-by: open-swe[bot] --- apps/open-swe/src/utils/github/api.ts | 39 +++++++++++++++------------ 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/apps/open-swe/src/utils/github/api.ts b/apps/open-swe/src/utils/github/api.ts index f2b9bbee..a50f25cd 100644 --- a/apps/open-swe/src/utils/github/api.ts +++ b/apps/open-swe/src/utils/github/api.ts @@ -203,9 +203,6 @@ export async function createPullRequest({ logger.info(`🐙 Pull request created: ${pullRequest.html_url}`); } catch (error) { if (nullOnError) { - logger.info("Pull request creation failed, returning null", { - nullOnError, - }); return null; } @@ -267,21 +264,29 @@ export async function markPullRequestReadyForReview({ title: string; body: string; githubInstallationToken: string; -}): Promise { - const octokit = new Octokit({ - auth: githubInstallationToken, - }); +}): Promise { + return withGitHubRetry( + async (token: string) => { + const octokit = new Octokit({ + auth: token, + }); - const { data: updatedPR } = await octokit.pulls.update({ - owner, - repo, - pull_number: pullNumber, - title, - body, - draft: false, - }); - logger.info(`Pull request #${pullNumber} marked as ready for review.`); - return updatedPR; + const { data: updatedPR } = await octokit.pulls.update({ + owner, + repo, + pull_number: pullNumber, + title, + body, + draft: false, + }); + logger.info(`Pull request #${pullNumber} marked as ready for review.`); + return updatedPR; + }, + githubInstallationToken, + "Failed to mark pull request as ready for review", + { pullNumber, owner, repo }, + 1, + ); } export async function getIssue({