From d0fe5f53235869dd00035c9c0e394ffa59fc80e3 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Mon, 28 Jul 2025 18:27:38 -0700 Subject: [PATCH] fix: Properly open a PR as ready for review (#579) * fix: Properly open a PR as ready for review * cr --- apps/open-swe/src/utils/github/api.ts | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/open-swe/src/utils/github/api.ts b/apps/open-swe/src/utils/github/api.ts index a50f25cd..c77d2cfa 100644 --- a/apps/open-swe/src/utils/github/api.ts +++ b/apps/open-swe/src/utils/github/api.ts @@ -271,14 +271,41 @@ export async function markPullRequestReadyForReview({ auth: token, }); + // Fetch the PR, as the markReadyForReview mutation requires the PR's node ID, not the pull number + const { data: pr } = await octokit.pulls.get({ + owner, + repo, + pull_number: pullNumber, + }); + + await octokit.graphql( + ` + mutation MarkPullRequestReadyForReview($pullRequestId: ID!) { + markPullRequestReadyForReview(input: { + pullRequestId: $pullRequestId + }) { + clientMutationId + pullRequest { + id + number + isDraft + } + } + } + `, + { + pullRequestId: pr.node_id, + }, + ); + 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; },