From cb03f6b3e88065eb89f693a6a463fbf7c1494fda Mon Sep 17 00:00:00 2001 From: ogt Date: Sun, 19 Apr 2026 16:11:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai-ops):=20HealLog=20DetachedInstanceError?= =?UTF-8?q?=20=E2=80=94=20expunge=20after=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit session.close() 後存取 heal_log.result 觸發 lazy reload 失敗。 在 close 前 expunge(hl) 讓物件帶著已載入屬性脫離 session。 Co-Authored-By: Claude Sonnet 4.6 --- services/auto_heal_service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/auto_heal_service.py b/services/auto_heal_service.py index 9c19cc5..76a594e 100644 --- a/services/auto_heal_service.py +++ b/services/auto_heal_service.py @@ -373,6 +373,7 @@ class AutoHealService: ) session.add(hl) session.commit() + session.expunge(hl) # detach after commit to keep loaded attrs return hl except Exception as e: session.rollback()