WeKnora icon indicating copy to clipboard operation
WeKnora copied to clipboard

[Bug]: 编辑角色打开智能体编辑器时,tenants/kv/storage-engine-config 返回 403 并中断整个依赖加载——模型/知识库下拉框为空,无法创建智能体

Open HideOnHub opened this issue 3 months ago • 1 comments

Affected Component

Frontend UI

Bug Description

【v0.7.2】编辑角色打开智能体编辑器时,tenants/kv/storage-engine-config 返回 403 并中断整个依赖加载——模型/知识库下拉框为空,无法创建智能体

Steps to Reproduce

复现步骤 以**编辑(Contributor)**角色邀请一个用户加入空间。 该用户登录(激活空间=该空间),进入 智能体 → 新建智能体 → 「模型配置」。 展开「对话模型」下拉框。

实际结果 下拉框内没有任何模型,只有“前往全局设置添加模型”一项; 重排/知识库区域显示“当前作用域内暂无 RAG 类型知识库”; 智能体无法创建(模型必填)。

Expected Behavior

编辑角色能够新建智能体

Actual Behavior

实际结果 下拉框内没有任何模型,只有“前往全局设置添加模型”一项; 重排/知识库区域显示“当前作用域内暂无 RAG 类型知识库”; 智能体无法创建(模型必填)。 A/B 对照实验(同一用户、同一空间,反复切换角色) 角色 编辑 → 管理员:两个下拉立即出现完整选项(7 个模型、8 个知识库); 角色 管理员 → 编辑:下拉再次全空; 多轮重复,症状与角色 1:1 对应。 服务端日志证据(同一时间段) 编辑角色打开编辑器时:

复制 GET /api/v1/tenants/kv/storage-engine-config → 403 GET /api/v1/models → 200, size=4432(7 个模型,数据完整) GET /api/v1/knowledge-bases → 200, size=16942(数据完整) 所有者/管理员打开编辑器时:

复制 GET /api/v1/tenants/kv/storage-engine-config → 200 GET /api/v1/models → 200, size=4734(数据完整) 即:数据接口对编辑角色同样返回完整列表,仅存储引擎配置的 KV 读取被拒(作为策略合理),但前端把它放大成了整体失败。

前端定位(v0.7.2 源码) AgentEditorModal.vue → loadDependencies():

ts 复制 await Promise.all([ chatResources.ensureModels(), chatResources.ensureKnowledgeBases(), chatResources.ensureWebSearchProviders(), editorResources.prefetchAgentEditorDeps(), // ← 内部 403 导致 reject ]); if (chatResources.allModels.length > 0) { allModels.value = chatResources.allModels; } const myKbs = chatResources.rawKnowledgeBases.map(...) kbOptions.value = [...myKbs, ...sharedKbs]; editorResources.prefetchAgentEditorDeps() 内部又是一层 Promise.all(含 ensureStorageEngine()),ensureStorageEngine() 请求的 /api/v1/tenants/kv/storage-engine-config 对编辑角色返回 403 → reject 向上传播 → loadDependencies 进入 catch(仅 console.error)→ allModels 与 kbOptions 从未被赋值 → 两个下拉渲染为空,界面无任何报错提示。

WeKnora Version

v0.7.2

Deployment Method

Docker Compose

Operating System

Ubuntu

Relevant Logs


Confirmation

  • [x] I have searched existing issues and confirmed this is a new one

HideOnHub avatar Sep 02 '26 09:09 HideOnHub

Reproduced and root-caused this on the current main, fix proposed in #3096.

Repro (API level): invited a Contributor member into a workspace and called GET /api/v1/tenants/kv/storage-engine-config with their token → 403 {"message":"integration configuration requires admin access"}; the Owner gets 200. The backend ACL itself looks deliberate (the config carries integration secrets).

Why it breaks the whole editor: editorResources.ensureStorageEngine awaited the admin-only config call and the Viewer-safe storage-engine-status call in one Promise.all. The 403 rejects that, which rejects prefetchAgentEditorDeps, which rejects AgentEditorModal.loadDependencies' Promise.all — and since the models/KB/web-search dropdown population sits after that await, everything stays empty for Contributors.

Fix: keep the config call best-effort — a 401/403 degrades to storageConfig = null (its only consumer already null-tolerates and falls back to the status list, which is what actually drives provider pickability), while other failures stay fatal. The status call remains required. Contributors then load the editor normally with the Viewer-safe endpoints.

vicfei avatar Sep 08 '26 01:09 vicfei