fix: return existing cost on empty PATCH body instead of 500
Build & Push Docker Image / build (push) Successful in 2m14s

This commit is contained in:
opencode
2026-08-02 01:31:55 +02:00
parent 6b8ca92c37
commit 32df998399
+5
View File
@@ -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);