From b0342db38e5cb6bc9e55b3828f43b4bbca7d64be Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 15 Sep 2026 18:07:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(db=5Fquery):=201054=E6=9C=AA=E7=9F=A5?= =?UTF-8?q?=E5=88=97=E9=94=99=E8=AF=AF=E5=9B=9E=E5=B8=A6=E8=A1=A8=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=88=97=E6=B8=85=E5=8D=95=E2=80=94=E2=80=94LLM?= =?UTF-8?q?=E6=8A=8Aparams=20JSON=E9=94=AE(stage/task=5Fkind)=E5=BD=93?= =?UTF-8?q?=E5=88=97=E4=BC=A0=E6=98=AF=E9=AB=98=E9=A2=91=E8=AF=AF=E7=94=A8?= =?UTF-8?q?,=E6=8A=A5=E9=94=99=E5=B8=A6=E5=88=97=E5=90=8D=E8=AE=A9?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E8=BD=AE=E8=87=AA=E6=81=A2=E5=A4=8D,?= =?UTF-8?q?=E4=B8=8D=E7=99=BD=E7=83=A7=E8=BD=AE=E6=AC=A1(2026-09-15?= =?UTF-8?q?=E7=94=98=E8=82=83=E9=A1=B9=E7=9B=AE=E5=AE=9E=E6=B5=8B=E6=8A=93?= =?UTF-8?q?=E5=88=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/db_query.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pipeline_service/db_query.py b/pipeline_service/db_query.py index 57e10dd..fb8c747 100644 --- a/pipeline_service/db_query.py +++ b/pipeline_service/db_query.py @@ -120,8 +120,18 @@ async def tool_query_project_data(sor, table: str, project_id: str, try: recs = await sor.sqlExe(full_sql, {"pid": project_id}) except Exception as e: + msg = str(e)[:200] + # 2026-09-15:LLM 常把 params JSON 键当列传(如 stage='analysis_redo')→ 1054。 + # 回带该表真实列清单,让调用方下一轮自恢复,不再白烧轮次。 + if 'Unknown column' in msg: + try: + cols = await sor.sqlExe("SHOW COLUMNS FROM " + table, {}) + names = ', '.join(getattr(c, 'Field', '') or '' for c in (cols or [])) + msg += '。表 %s 可用列: %s(stage/task_kind 等在 params JSON 内,不是列)' % (table, names) + except Exception: + pass # 产线扩展表在其他产线库可能不存在——容错但报实情 - return 'FAIL: 查询异常(表可能不存在于当前产线库): ' + str(e)[:200] + return 'FAIL: 查询异常(表可能不存在于当前产线库): ' + msg rows = [_rec_to_dict(r) for r in (recs or [])] # 审计(append-only):谁在查什么