From 7c668176999c76da63e7fd24503d4653e384485c Mon Sep 17 00:00:00 2001 From: Pbhacks Date: Sun, 8 Mar 2026 18:25:03 +0530 Subject: [PATCH] fix(filler): replace timestamp filename with uuid4 to prevent race condition Resolves #198 The output PDF filename was generated using datetime.now().strftime('%Y%m%d_%H%M%S') which has only 1-second resolution. Two concurrent requests in the same second produced identical output paths, causing one to silently overwrite the other. Replaced with uuid4() to guarantee globally unique filenames regardless of timing. --- src/filler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/filler.py b/src/filler.py index e31e535..c99e8e2 100644 --- a/src/filler.py +++ b/src/filler.py @@ -1,6 +1,6 @@ from pdfrw import PdfReader, PdfWriter from src.llm import LLM -from datetime import datetime +from uuid import uuid4 class Filler: @@ -15,7 +15,7 @@ def fill_form(self, pdf_form: str, llm: LLM): output_pdf = ( pdf_form[:-4] + "_" - + datetime.now().strftime("%Y%m%d_%H%M%S") + + str(uuid4()) + "_filled.pdf" )