From 03ca12496786f0def0c4f5a40e0e47985029ccdf Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 23 Mar 2026 22:02:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=5Fpersist=5Fincident=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=A1=AF=E5=BC=8F=20commit=20+=20=E8=BF=BD=E8=B9=A4?= =?UTF-8?q?=E6=97=A5=E8=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: DB 變更未被 commit,導致 Incident 狀態更新不持久化 Co-Authored-By: Claude Opus 4.5 --- apps/api/src/services/proposal_service.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/api/src/services/proposal_service.py b/apps/api/src/services/proposal_service.py index 1fc45edc5..905b9246a 100644 --- a/apps/api/src/services/proposal_service.py +++ b/apps/api/src/services/proposal_service.py @@ -493,6 +493,13 @@ class ProposalService: record.status = incident.status.value record.proposal_ids = [str(pid) for pid in incident.proposal_ids] record.updated_at = incident.updated_at + # 顯式 commit 確保變更持久化 + await db.commit() + logger.info( + "db_incident_updated", + incident_id=incident.incident_id, + new_status=incident.status.value, + ) except Exception as e: logger.warning( @@ -524,6 +531,12 @@ class ProposalService: Returns: 是否更新成功 """ + logger.info( + "resolve_incident_starting", + incident_id=incident_id, + approval_id=approval_id, + ) + try: incident = await self._load_incident(incident_id) if not incident: @@ -534,6 +547,12 @@ class ProposalService: ) return False + logger.info( + "resolve_incident_loaded", + incident_id=incident_id, + current_status=incident.status.value, + ) + # 更新狀態 old_status = incident.status incident.status = IncidentStatus.RESOLVED