Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[Bug] v0.3.16「模型目录」页面黑屏崩溃:新模型 genie-4 返回 methods: null 导致前端 TypeError #349

Done

Description

@AlorsViensJouerDehors

发生了什么 / What happened

版本与环境

  • 版本:v0.3.16(Windows amd64)
  • 问题页面:管理端「模型目录」(/?tab=models)及部分依赖模型 methods 的视图

现象

刷新账号模型目录后(账户目录下拉到了新上线的 models/genie-4),点击左侧「模型目录」标签页时,右侧内容区完全黑屏/空白,无法展示任何模型。

排查定位

  1. 请求 /api/models 接口返回 HTTP 200(共 50 个模型),其中新模型 genie-4 的返回体中 methods 字段为 null(而非空数组 []):
    {
      "id": "genie-4",
      "name": "Genie 4",
      "description": "Real-time audio-video generation model",
      "version": "001",
      "methods": null,
      "access_modes": [1],
      "paid": true
    }
  2. 前端 ModelsTable(以及 AccessPanel 等读取 model.methods 的组件)在渲染和计算过滤选项时直接对 methods 做了数组展开/遍历(例如 j.models.flatMap(e => e.methods)、t.methods.includes(...)、t.methods 迭代等),遇到 null 时抛出未捕获的 TypeError,导致整个页面组件渲染中断。

建议修复

  • 后端:序列化 /api/models 时保证 methods 至少为空数组 [],避免输出 null。
  • 前端:对 model.methods 增加空值兜底(如 model.methods ?? []),防止未来再有特殊模型缺少 methods 时整页白屏/黑屏。

版本 / Version

No response

Activity

  1. shaka999 commented on Dec 2, 2026

    @shaka999

    同一问题的补充确认(Docker 部署,非 Windows),并补一条 issue 里还没提到的绕过路径失效原因。

    我的环境

    • 镜像:ghcr.io/mag1cfall/aistudio2api:latest(v0.3.16),Linux amd64,跑在 x86 路由器(ImmortalWrt)上
    • 账户:2 个(1 个付费 Pro、1 个家庭共享 Pro),均 benefit_tier: Pro
    • /api/models 返回 50 个模型,/v1/models 返回 65 个

    复现与确认

    • /api/models → HTTP 200,164812 字节,数据完整
    • methods 为 null 的模型只有 genie-4 一个("methods":[] 出现 0 次,说明上游对它是 null 而非空数组)
    • /api/events(SSE)首个快照里 models 事件完整,274610 字节,gemini-4-argon 在其中出现 16 次 —— 说明数据层和传输层都正常
    • 但「模型目录」页显示为空白(不是黑屏,是整个内容区无任何文字),loading、models.empty、models.noMatches 三种状态都渲染不出来

    前端崩溃点定位(v0.3.16 实际发布的 ModelsTable-B64vDgQC.js)

    命中 5 处对 .methods 的直接使用,第 1 处会先抛错并中断整条 computed 链:

    // ① 筛选下拉选项 —— 首崩点,null 不可迭代
    Ft=d(()=>re([...new Set(j.models.flatMap(e=>e.methods))].sort((e,t)=>e.localeCompare(t)),I.value,``))
    
    // ② 搜索匹配 —— 展开 null
    [t.id,t.name,t.description??``,...t.methods,...n].some(t=>t.toLowerCase().includes(e))
    
    // ③ 方法筛选
    i=I.value===``||t.methods.includes(I.value)
    
    // ④ 提示图标
    Y(e){return e.methods.includes(`createDecision`)?`models.decisionHiddenHelp`:e.hidden?`models.hiddenHelp`:null}
    
    // ⑤ 详情面板
    o.config&&V.value.length>2&&R.value.methods.includes(`generateContent`)

    重要补充:HIDE_MODELS 无法绕过此问题

    看到有人可能想用 HIDE_MODELS=genie-4 避开,实测无效。原因在服务端路径:

    /api/models → handleAdminModels → CatalogModels(ctx) → service.catalogModels() → pool.CatalogModels(...)

    而 internal/app/model_visibility.go 里的 visibleModels() / modelUnavailable() 只作用于公开 API(/v1/models 与请求路由)。管理页的 /api/models 完全不经过这层过滤。

    所以隐藏后:

    • /v1/models 里 genie-4 消失 ✅
    • /api/models 里 genie-4 仍在(实测 "methods":null 依然出现 1 次)❌ → 前端照崩

    顺带一条:降级到 v0.3.15 也解决不了

    genie-4 是 2026-12-01 才进入目录的,但 flatMap(e=>e.methods) 这类写法在 v0.3.15 的 ModelsTable 里同样存在(不是本次改动引入的回归)。降级后只要账户目录里还有 genie-4,页面依旧空白,除非同时回退 auth/<邮箱>/catalog.json,而该文件没有版本备份。

    建议修复(同原 issue,但请前端后端都做)

    1. 后端(更彻底):Model.Methods 序列化时 nil → [],从根上消灭 null
    2. 前端:上述 5 处统一加 ?? [] 兜底,防止未来再有模型缺 methods 时整页失效

    另:genie-4 本身在我这边也不可用(does not support generateContent,走 chat completions 返回 404),它是实时音视频模型,所以 methods 里确实没有 generateContent。也就是说这个模型目前对 Playground 通道是纯负担,如果能顺便在目录里给它标成不可用于 PG,也能避免同类问题。

  2. CCunicorn commented on Dec 3, 2026

    @CCunicorn

    补充一个 Docker 部署下的独立复现(Linux amd64 / 镜像 ghcr.io/mag1cfall/aistudio2api:latest = v0.3.16,/api/update 显示已是最新)。

    /api/models 返回 52 个模型,methods 为 null 的同样只有 genie-4。

    控制台仅 1 条未捕获异常,内容区整块空白,其他标签页正常:
    TypeError: Cannot read properties of null (reading 'includes')
    栈顶为 ModelsTable-B64vDgQC.js:2,实际调用点是
    Y(e){return e.methods.includes('createDecision')? ... : null}

    直接刷新 ?tab=models 与从其他标签切回都会复现。

    修复建议同上:服务端把 methods 兜底为 [],前端统一 methods ?? []。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions