From b09713923ea7d7ea3895675cccb18f1e99e649b7 Mon Sep 17 00:00:00 2001 From: Tobias Wilken Date: Sun, 14 Dec 2025 09:42:45 +0100 Subject: [PATCH] fix: skip draft PRs from processing Draft PRs cannot be merged by GitHub and attempting to do so results in a 405 error. This change skips draft PRs in both scheduled processing and webhook handling to avoid unnecessary API calls and error logs. Closes #199 --- src/helpers/pullRequestProcessor.js | 13 +++++++++++++ src/helpers/webhookHandler.js | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/helpers/pullRequestProcessor.js b/src/helpers/pullRequestProcessor.js index 04d69c2..1de14d9 100644 --- a/src/helpers/pullRequestProcessor.js +++ b/src/helpers/pullRequestProcessor.js @@ -122,6 +122,14 @@ export async function processPullRequests() { console.log(`Found ${pullRequests.length} pull requests`); for (const pullRequest of pullRequests) { + // Skip draft PRs - they cannot be merged and should not be processed + if (pullRequest.draft) { + console.log( + `⏸️ Skipping draft PR #${pullRequest.number}: ${pullRequest.title}` + ); + continue; + } + const prResult = { number: pullRequest.number, title: pullRequest.title, @@ -303,6 +311,11 @@ export async function processRepositoryPullRequests(owner, repo) { const results = []; for (const pullRequest of pullRequests) { + // Skip draft PRs + if (pullRequest.draft) { + continue; + } + const pullRequestData = await getPullRequestData( githubClient, owner, diff --git a/src/helpers/webhookHandler.js b/src/helpers/webhookHandler.js index ed7dfd8..e95411c 100644 --- a/src/helpers/webhookHandler.js +++ b/src/helpers/webhookHandler.js @@ -120,6 +120,14 @@ export async function handlePullRequestWebhook(data) { return { error: 'No GitHub App configured' }; } + // Skip draft PRs - they cannot be merged and should not be processed + if (pullRequest.draft) { + console.log( + `⏸️ Skipping draft PR #${pullRequest.number}: ${pullRequest.title}` + ); + return { info: 'Draft PR skipped' }; + } + try { const installationId = dbRepository.installationId; @@ -204,6 +212,14 @@ export async function handlePullRequestReviewWebhook(data) { return { error: 'No GitHub App configured' }; } + // Skip draft PRs + if (pullRequest.draft) { + console.log( + `⏸️ Skipping review for draft PR #${pullRequest.number}: ${pullRequest.title}` + ); + return { info: 'Draft PR review skipped' }; + } + try { const installationId = dbRepository.installationId;