From 32df9983995415a9f5bcad586ed93f57b1a9e2e9 Mon Sep 17 00:00:00 2001 From: opencode Date: Sun, 2 Aug 2026 01:31:55 +0200 Subject: [PATCH] fix: return existing cost on empty PATCH body instead of 500 --- artifacts/api-server/src/routes/costs.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/artifacts/api-server/src/routes/costs.ts b/artifacts/api-server/src/routes/costs.ts index 56f1617..e054f26 100644 --- a/artifacts/api-server/src/routes/costs.ts +++ b/artifacts/api-server/src/routes/costs.ts @@ -91,6 +91,11 @@ router.patch("/costs/:id", requireAuth, requireFeature("costs"), async (req, res if (currency !== undefined) updateData.currency = currency; if (notes !== undefined) updateData.notes = notes; + if (Object.keys(updateData).length === 0) { + res.json(existing); + return; + } + const [updated] = await db.update(toolCostsTable).set(updateData).where(eq(toolCostsTable.id, id)).returning(); await writeAuditLog(req, "tool_cost", id, "update", { toolId: existing.toolId, ...updateData }); res.json(updated);