From fff7bace285e33ee93069436241b1cb6ebfc38f9 Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 10 Aug 2026 17:53:27 +0800 Subject: [PATCH] fix: handle missing answered column in questions table --- pipeline_service/agent_loop_v2.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index 1d6f86a..688b749 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -643,15 +643,20 @@ class AgentExecutor: review = await sor.sqlExe( "SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='review'", {"pid": pid}) - questions = await sor.sqlExe( - "SELECT COUNT(*) as c FROM pipeline_agent_questions WHERE tenant_id=${pid}$ AND answered IS NULL", - {"pid": pid}) + # questions 表可能没有 answered 列,用 try/except 兜底 + qc = 0 + try: + questions = await sor.sqlExe( + "SELECT COUNT(*) as c FROM pipeline_agent_questions WHERE tenant_id=${pid}$ AND answered IS NULL", + {"pid": pid}) + qc = getattr(questions[0], "c", 0) if questions else 0 + except Exception: + pass sc = getattr(submitted[0], "c", 0) if submitted else 0 rc = getattr(running[0], "c", 0) if running else 0 fc = getattr(failed[0], "c", 0) if failed else 0 vc = getattr(review[0], "c", 0) if review else 0 - qc = getattr(questions[0], "c", 0) if questions else 0 return ( f"项目诊断:\n"