fix: list_messages/模型下拉产线隔离缺口
- list_messages原无过滤返回全表→按user+session+pipeline过滤(跨产线/跨用户泄漏) - agent_model_options接收pipeline_id并传给get_session_project_id,防跨产线项目劫持模型选中态
This commit is contained in:
parent
c0e8557ef8
commit
d05571cc96
@ -141,10 +141,25 @@ elif action == 'list_messages':
|
||||
uid = await get_user()
|
||||
if not uid:
|
||||
return json.dumps({"error": "请先登录"}, ensure_ascii=False)
|
||||
# 产线隔离(2026-09-02):必须按 user + session + pipeline 过滤。
|
||||
# 旧实现无过滤返回全表——跨产线/跨用户会话历史泄漏。
|
||||
_sid = (params_kw or {}).get('session_id', '') or ''
|
||||
_pl = (params_kw or {}).get('pipeline_id', '') or ''
|
||||
_sql = ("SELECT role, content, created_at FROM pipeline_conversations "
|
||||
"WHERE created_by=${u}$")
|
||||
_kw = {"u": uid, "lim": 100}
|
||||
if _sid:
|
||||
_sql += " AND session_id=${sid}$"
|
||||
_kw["sid"] = _sid
|
||||
if _pl:
|
||||
_sql += " AND pipeline_id=${pl}$"
|
||||
_kw["pl"] = _pl
|
||||
# DESC+LIMIT 取最新再倒序(与 _load_history 隔离策略一致;ASC+LIMIT 会取最旧)
|
||||
_sql += " ORDER BY created_at DESC LIMIT ${lim}$"
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
ms = await sor.sqlExe(
|
||||
"SELECT role,content,created_at FROM pipeline_conversations ORDER BY created_at ASC LIMIT 100", {})
|
||||
result = [{"role": getattr(m, 'role', ''), "content": getattr(m, 'content', '')} for m in (ms or [])]
|
||||
ms = await sor.sqlExe(_sql, _kw)
|
||||
result = [{"role": getattr(m, 'role', ''), "content": getattr(m, 'content', '')}
|
||||
for m in reversed(ms or [])]
|
||||
return json.dumps({"success": True, "messages": result}, ensure_ascii=False, default=str)
|
||||
|
||||
else:
|
||||
|
||||
@ -13,6 +13,7 @@ dbname = get_module_dbname('pipeline_core')
|
||||
uid = await get_user()
|
||||
org_id = (await get_userorgid()) or ''
|
||||
session_id = (params_kw or {}).get('session_id', '') or ''
|
||||
pipeline_id = (params_kw or {}).get('pipeline_id', '') or ''
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
sql = "SELECT id, name, provider, model_id, capabilities FROM llm WHERE status='active'"
|
||||
@ -28,7 +29,9 @@ async with DBPools().sqlorContext(dbname) as sor:
|
||||
project_model = ''
|
||||
try:
|
||||
from pipeline_service.workspace import get_session_project_id
|
||||
_pid = await get_session_project_id(sor, uid or '', session_id)
|
||||
# 产线隔离(2026-09-02):传入口产线,跨产线项目不算本会话项目——
|
||||
# 否则平台/其他产线页面的模型选中态会被投标项目的 default_model 劫持
|
||||
_pid = await get_session_project_id(sor, uid or '', session_id, pipeline_id)
|
||||
if _pid:
|
||||
_p = await sor.sqlExe(
|
||||
"SELECT default_model FROM sd_projects WHERE id=${p}$", {"p": _pid})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user