⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(api): gitlab webhook now failures with 500
zaralXdf6fc43bfa1e
diff --git a/apps/api/src/gitlab-integration/index.ts b/apps/api/src/gitlab-integration/index.tsindex 356e653b2..c3bef795d 100644--- a/apps/api/src/gitlab-integration/index.ts+++ b/apps/api/src/gitlab-integration/index.ts@@ -357,7 +357,7 @@ export async function handleGitlabWebhookRoute(c: Context) {const result = await handleGitlabWebhookRequest(integrationId, body, token);if (!result.success) {- return c.json({ error: result.error }, 400);+ return c.json({ error: result.error }, result.status ?? 400);}return c.json({ status: "success" });diff --git a/apps/api/src/plugins/gitlab/webhook-handler.ts b/apps/api/src/plugins/gitlab/webhook-handler.tsindex 60eab52be..cc9ebf4a9 100644--- a/apps/api/src/plugins/gitlab/webhook-handler.ts+++ b/apps/api/src/plugins/gitlab/webhook-handler.ts@@ -92,7 +92,7 @@ export async function handleGitlabWebhookRequest(integrationId: string,rawBody: string,tokenHeader: string | undefined,-): Promise<{ success: boolean; error?: string }> {+): Promise<{ success: boolean; error?: string; status?: 400 | 500 }> {const integration = await db.query.integrationTable.findFirst({where: eq(integrationTable.id, integrationId),});@@ -136,10 +136,8 @@ export async function handleGitlabWebhookRequest(return { success: true };} catch (error) {console.error("[GitLab Webhook] Handler error:", error);- return {- success: false,- error: error instanceof Error ? error.message : "Webhook handler failed",- };+ // The request itself was valid; the details stay in the server log.+ return { success: false, error: "Webhook handler failed", status: 500 };}}diff --git a/tests/api/plugins/gitlab/webhook-handler.test.ts b/tests/api/plugins/gitlab/webhook-handler.test.tsindex f2e9868b5..fa1c6155d 100644--- a/tests/api/plugins/gitlab/webhook-handler.test.ts+++ b/tests/api/plugins/gitlab/webhook-handler.test.ts@@ -216,6 +216,27 @@ describe("handleGitlabWebhookRequest merge request updates", () => {});});+describe("handleGitlabWebhookRequest handler failures", () => {+ it("reports a failing handler as a server error without its details", async () => {+ mocks.handleGitlabIssueClosed.mockRejectedValueOnce(+ new Error('duplicate key value violates unique constraint "task_pkey"'),+ );+ vi.spyOn(console, "error").mockImplementationOnce(() => undefined);++ const result = await handleGitlabWebhookRequest(+ "integration-1",+ issueEvent({ action: "close" }),+ secret,+ );++ expect(result).toEqual({+ success: false,+ error: "Webhook handler failed",+ status: 500,+ });+ });+});+describe("handleGitlabWebhookRequest confidential issues", () => {it("passes a regular issue update to the handler", async () => {await handleGitlabWebhookRequest(