Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(github): only ignore missing label removals

Tin399c7977d723
diff --git a/apps/api/src/plugins/github/utils/labels.ts b/apps/api/src/plugins/github/utils/labels.ts
index dd2343b08..91166d192 100644
--- a/apps/api/src/plugins/github/utils/labels.ts
+++ b/apps/api/src/plugins/github/utils/labels.ts
@@ -81,5 +81,17 @@ export async function removeLabel(
issue_number: issueNumber,
name: labelName,
});
- } catch {}
+ } catch (error) {
+ if (
+ typeof error === "object" &&
+ error !== null &&
+ "status" in error &&
+ error.status === 404
+ ) {
+ return;
+ }
+
+ console.error(`Failed to remove label "${labelName}" from issue:`, error);
+ throw error;
+ }
}
diff --git a/tests/api/plugins/github/utils/labels.test.ts b/tests/api/plugins/github/utils/labels.test.ts
index a6a7c98d1..abcc344c0 100644
--- a/tests/api/plugins/github/utils/labels.test.ts
+++ b/tests/api/plugins/github/utils/labels.test.ts
@@ -66,12 +66,22 @@ describe("github labels helpers", () => {
});
});
- it("swallows label removal errors", async () => {
+ it("ignores missing labels during removal", async () => {
const octokit = createOctokitMock();
- octokit.rest.issues.removeLabel.mockRejectedValue(new Error("gone"));
+ octokit.rest.issues.removeLabel.mockRejectedValue({ status: 404 });
await expect(
removeLabel(octokit as never, "usekaneo", "kaneo", 21, "status:done"),
).resolves.toBeUndefined();
});
+
+ it("rethrows unexpected label removal errors", async () => {
+ const octokit = createOctokitMock();
+ const error = new Error("gone");
+ octokit.rest.issues.removeLabel.mockRejectedValue(error);
+
+ await expect(
+ removeLabel(octokit as never, "usekaneo", "kaneo", 21, "status:done"),
+ ).rejects.toThrow("gone");
+ });
});