From 8b845261d28c9e402114bae39c55f0b131e20de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=8D?= Date: Fri, 29 Aug 2025 22:12:23 +0200 Subject: [PATCH] fix: prevent empty file from overwriting existing bill attachments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix updateOrAddBill to check file size before processing attachment, preventing empty blob files from overwriting existing attachments when updating bill properties. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- app/lib/actions/billActions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/lib/actions/billActions.ts b/app/lib/actions/billActions.ts index 89a22fb..2ebb595 100644 --- a/app/lib/actions/billActions.ts +++ b/app/lib/actions/billActions.ts @@ -150,7 +150,9 @@ export const updateOrAddBill = withUser(async (user:AuthenticatedUser, locationI // update the bill in the mongodb const dbClient = await getDbClient(); - const billAttachment = await serializeAttachment(formData.get('billAttachment') as File); + const billAttachmentFile = formData.get('billAttachment') as File; + const billAttachment = billAttachmentFile && billAttachmentFile.size > 0 ? + await serializeAttachment(billAttachmentFile) : null; if(billId) {