scense/_archive_dead_dspy/add_reseller.dspy.20261028_154412
ymq 0cfeb45a3c fix(dspy): 修复 5 个 dspy 的 await-outside-async 语法错误 + 归档死文件
背景:移除 24 个自造鉴权中间件后(上一条 commit 702f274),原本被中间件
提前拦截的请求真正走到 dspy 执行层,暴露出存量语法错误——这些端点此前
一律被中间件返回 401/405,从未真正执行过。

根因:agent 往 dspy 头部注入 ns-shim 段时,把含 await 的辅助函数
(_auth_resolve_uid / _ns_export)写成同步 def,而 ahserver 的
PythonScriptProcessor 只把整个文件包进 async myfunc,函数体内的 await
成为编译期 SyntaxError。

修复(5 个文件,模式一致:同步 def -> async def + 调用点加 await):
  - runtime/api/runtime_status.dspy   (_auth_resolve_uid, _ns_export)
  - runtime/api/build_entity_tree.dspy (同上)
  - scense/api/list_scense.dspy        (同上)
  - scene/api/get_search_scene_type.dspy (同上)
  - scene/api/get_search_status.dspy     (同上)

另归档 _archive_dead_dspy/add_reseller.dspy:该文件未跟踪、非 rbac 自带
(宿主 rbac 无此文件),且依赖 rbac 中不存在的 openCustomerAccounts,
纯属自造死文件,保留只会持续 500。

验证:
  - 全量扫描 184 个 dspy(按 ahserver 包装方式 compile):语法错误 0
  - 带 cookie 实测 6 个端点全部 200:healthz / runtime_status /
    build_entity_tree / list_scense / get_search_status / get_search_scene_type
  - login 200 + cookie、匿名 401 保持正常
2026-10-28 15:45:30 +08:00

27 lines
647 B
Plaintext

ns = params_kw.copy()
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
db = DBPools()
dbname = get_module_dbname('rbac')
async with db.sqlorContext(dbname) as sor:
ownerid = await get_userorgid()
await create_org(sor, ns, orgtypes=['customer', 'reseller'])
if openCustomerAccounts:
await openCustomerAccounts(sor, ownerid, orgid)
if openResellerAccounts:
await openResellerAccounts(sor, ownerid, id)
return UiMessage(title="Success", message="add reseller success")
return {
"widgettype":"Error",
"options":{
"title":"Add reseller Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}