From f27a9b6fe4274967a36cf4babc499596480f4652 Mon Sep 17 00:00:00 2001 From: Ermin Muratovic Date: Fri, 6 Mar 2026 14:43:18 +0000 Subject: [PATCH] feat: Fix: PRs appear in open issues list (GitHub API treats PRs as issues) Co-Authored-By: Claude Sonnet 4.6 --- .../github/OctokitGitHubClient.ts | 3 +- .../OctokitGitHubClient.test.ts | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/github/OctokitGitHubClient.ts b/src/infrastructure/github/OctokitGitHubClient.ts index 6250413..abe1b00 100644 --- a/src/infrastructure/github/OctokitGitHubClient.ts +++ b/src/infrastructure/github/OctokitGitHubClient.ts @@ -76,7 +76,8 @@ export class OctokitGitHubClient implements GitHubClient { milestone: milestoneId as unknown as string, state: "all", }); - return data.map((d) => this.mapIssue(d)); + const filteredIssues = data.filter((item) => !item.pull_request); + return filteredIssues.map((d) => this.mapIssue(d)); } async createBranch(name: string, fromBranch: string): Promise { diff --git a/tests/infrastructure/OctokitGitHubClient.test.ts b/tests/infrastructure/OctokitGitHubClient.test.ts index 155f940..cd1ba4a 100644 --- a/tests/infrastructure/OctokitGitHubClient.test.ts +++ b/tests/infrastructure/OctokitGitHubClient.test.ts @@ -148,6 +148,36 @@ describe("OctokitGitHubClient", () => { ); }); + it("should exclude pull requests from listIssues results", async () => { + mockOctokit.issues.listForRepo.mockResolvedValueOnce({ + data: [ + { + id: 1, + number: 1, + title: "Real Issue", + body: "An actual issue", + labels: [{ name: "bug" }], + milestone: null, + }, + { + id: 2, + number: 2, + title: "A Pull Request", + body: "A PR masquerading as issue", + labels: [], + milestone: null, + pull_request: { url: "https://api.github.com/repos/owner/repo/pulls/2" }, + }, + ], + }); + + const result = await client.listIssues(); + + expect(result).toHaveLength(1); + expect(result[0].number).toBe(1); + expect(result[0].title).toBe("Real Issue"); + }); + it("should create branch by fetching SHA first then creating ref", async () => { mockOctokit.git.getRef.mockResolvedValueOnce({ data: { object: { sha: "abc123" } },