From 3c3cc95a622e71c3845aaf05cf6f7ced2d7466c1 Mon Sep 17 00:00:00 2001 From: yongtenglei Date: Tue, 2 Dec 2025 14:06:03 +0800 Subject: [PATCH] AttributeError: 'NoneType' object has no attribute 'timestamp' --- api/db/services/document_service.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/api/db/services/document_service.py b/api/db/services/document_service.py index 7b7ef53ec..395dcad83 100644 --- a/api/db/services/document_service.py +++ b/api/db/services/document_service.py @@ -719,10 +719,14 @@ class DocumentService(CommonService): # only for special task and parsed docs and unfinished freeze_progress = special_task_running and doc_progress >= 1 and not finished msg = "\n".join(sorted(msg)) + begin_at = d.get("process_begin_at") + if not begin_at: + begin_at = datetime.now() + # fallback + cls.update_by_id(d["id"], {"process_begin_at": begin_at}) + info = { - "process_duration": datetime.timestamp( - datetime.now()) - - d["process_begin_at"].timestamp(), + "process_duration": max(datetime.timestamp(datetime.now()) - begin_at.timestamp(), 0), "run": status} if prg != 0 and not freeze_progress: info["progress"] = prg