Skip to content

Web UI "Save Key" has no server route — PUT /__bili/external-summary/credential 404s, so external-summary credentials can never be saved from the UI #3443

Closed

Description

@SivaGeeky

Summary

On the config page, the Recipe credentials panel renders for a recipe with a secret: ref, but Save Key cannot persist anything. The UI issues PUT /__bili/external-summary/credential, which the running proxy does not register; the router's generic admin-path fallback returns 404 {"error":{"type":"not_found","message":"no such management endpoint"}}. The credential store file is never created, so the chain keeps failing with credential secret:<masked> did not resolve to a value — it will be skipped until fixed.

Environment

Same as Issue 1: 0.1.197 / 3aeddc16, hermes-plugin, Windows 11, proxy on 127.0.0.1:18787.

Repro

  1. Configure a named recipe (e.g. deepseek) with credentialRef: "deepseek" so the panel appears.
  2. Open http://127.0.0.1:18787/__bili/#/config → Recipe credentials → API Key → Save Key.
  3. Error in the UI; the same request by hand returns:
    PUT /__bili/external-summary/credential
    → 404 {"error":{"type":"not_found","message":"no such management endpoint"}}
    
  4. Store file <config>.summary-credentials.json is never created.
  5. Chain log keeps repeating:
    [external-summary] candidate deepseek--deepseek-chat unavailable: credential secret:<masked 8 chars> did not
    resolve to a value — it will be skipped until fixed
    

Evidence

  • The UI served by the same proxy (GET /__bili/) contains exactly this call:
    const result = await json("/__bili/external-summary/credential", {
      method: "PUT",
      headers: { "content-type": "application/json" },
      body: JSON.stringify({ name: recipe.credentialRef, key: value })
    });
    Labels: summary.credentials = "Recipe credentials", summary.key = "API Key", summary.key_save = "Save Key", summary.key_missing = "Not configured".
  • GET /__bili/ exposes this admin path set — /__bili/config, /__bili/conflicts/clear, /__bili/host-plugins/dismiss, /__bili/overview, /__bili/resign, /__bili/sessions/, /__bili/upstream, /__bili/upstream/test — plus /__bili/external-summary/credential, which is the only one without a server route.
  • dist/index.js router fallback produces the observed body for any unregistered /__bili/* path:
    if (isAdminPath) {
      res.writeHead(404, {"content-type":"application/json"});
      res.end(JSON.stringify({error:{type:"not_found",message:"no such management endpoint"}}));
      return;
    }
    with isAdminPath = req.url === "/__bili/" || req.url.startsWith("/__bili/") — so the path is recognized as admin, it is simply not registered.
  • Grep of dist/index.js: external-summary appears only in chain parsing / summarising code (parseExternalSummaryChain, [external-summary] completed …, candidate construction, EXTERNAL_SUMMARY_CALL_ID_PREFIX), never in an HTTP route registration.
  • Ruled out: loopback and origin gates. Request came from 127.0.0.1 with matching Origin/Referer headers and still 404s (a genuine gate failure returns 403 with a distinct message).

Expected

Either register PUT /__bili/external-summary/credential (the shipped UI depends on it), or drop the button until the route exists.

Workaround that works (for anyone blocked today)

Write the store by hand — a flat { "<name>": "<key>" } JSON map at <config>.summary-credentials.json:

$path = "C:\Users\gsiva\.config\billion-context\billion-context.json.summary-credentials.json"
$json = '{"deepseek":"PASTE_YOUR_KEY"}'
[System.IO.File]::WriteAllText($path, $json, (New-Object System.Text.UTF8Encoding($false)))  # no BOM

Notes: SummaryCredentialStore.read() accepts exactly that shape (validKey forbids whitespace/control chars, ≤8192 bytes); the store is read at resolution time so no restart is needed; do not leave a ${path}.lock file behind (set() takes it with wx, so a stale lock makes writes fail with "External summary credential store is locked or unavailable").

Update (same install) — this bug is the only thing that was blocking external summary

With the store written by hand, the very next qualifying requests went from
[external-summary] completed (preflight) 1/1 range(s); batch=finished result=failed reason=exhausted attempts=[t0:error]
to
[external-summary] completed (preflight) 4/4 range(s); calls=4; batch=finished result=success attempts=[t0:success]
and auto-fold started landing blocks. So the missing route was the whole blocker.

Activity

  1. ranxianglei commented on Oct 16, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    查重: 无 — open/closed issues 和 PR 里都没有同类报告(按 external-summary / credential / Save Key / 404 组合检索)。

    结论:bug 属实,根因已钉死,正在修。

    验证结果(在 master 和 0.1.197 上均成立):

    • 处理器 handleSummaryCredentialPut 一直存在(src/web/api.ts:141),校验、私有存储、删除语义都是完整的;Web UI 的 Save Key 按钮也一直存在(src/web/client.ts:2576)。
    • 但路由注册丢了:所有 /__bili/* 管理路由现在集中在 src/server/admin.ts 的 handleAdminRoute(audit: 全仓冗余审计与重构计划——server.ts 解体、客户端矩阵去重、死代码、AGENTS.md 模块图腐化 #1440 P2 cut 1 重构),里面没有 /__bili/external-summary/credential 这一条 → 落到兜底 404。你手写的 store 文件能立即生效,正是因为存储读取发生在 resolve 时、与路由无关——缺路由是唯一的阻塞点,和你观察到的完全一致。

    根因(git 取证):

    1. bcf40118d(external summary 功能)当时把这条路由写在 src/server.ts 里;
    2. 273c83945(admin 路由面抽到 admin.ts 的重构)把 server.ts 里的管理路由全部搬走;
    3. 功能分支合入 master 的 merge(PR feat: 统一外部摘要模型、顺序故障转移与多客户端压缩接线 #2167)落在重构之后,合并时静默丢掉了这条新路由行——典型的 stale-base 语义冲突丢失。server.ts 里还留着一行引用该处理器的死 import(其余符号也全是死的),所以 typecheck 一直是绿的;现有测试直接调处理器而不经过真实路由器,CI 也绿。

    修复方案(进行中):

    1. 在 src/server/admin.ts 注册该路由(继承与兄弟管理路径相同的 loopback + trusted-origin 门禁);
    2. 清掉 server.ts 的死 import(同一重构遗留,单独标注 commit);
    3. 新增一个经过真实路由器的回归测试(现有测试绕开了路由器,这正是 CI 漏掉它的原因)。

    行为变更声明:PUT /__bili/external-summary/credential 从「永远 404」变为可用端点(loopback + origin 门禁,与其他 /__bili 管理路径一致);无其他行为变化。

    PR 开好会在本线程更新链接。

  2. ranxianglei commented on Oct 16, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    修复完成,PR: #3445 (Closes #3445 引用本 issue,等 CI + 人工合并)

    八问:

    1. 是什么问题:Web UI 配置页的 Save Key 按钮发的 PUT /__bili/external-summary/credential 在路由器上从未注册,永远 404——external-summary 的密钥只能靠手写 <config>.summary-credentials.json 保存。
    2. 什么原因导致的:功能提交(bcf40118d)把路由写在 src/server.ts;随后「admin 路由面抽到 admin.ts」的重构(273c83945,audit: 全仓冗余审计与重构计划——server.ts 解体、客户端矩阵去重、死代码、AGENTS.md 模块图腐化 #1440 P2 cut 1)把全部管理路由搬走;功能分支在重构之后合入(PR feat: 统一外部摘要模型、顺序故障转移与多客户端压缩接线 #2167),merge 解析时把这条新路由行静默丢掉(stale-base 语义冲突丢失)。处理器、UI、handler 级测试都幸存,只丢了路由接线;server.ts 还留着一行死 import,现有测试绕过真实路由器直接调 handler——所以 typecheck 和 CI 一直是绿的。
    3. 影响范围与严重程度:自该 merge 起的所有版本(含你用的 0.1.197)和 master。影响面:所有想用 secret:<name> 凭据引用保存密钥的 external-summary 用户;程度 = 特定功能完全不可用(UI 保存路径断掉),无崩溃、无数据丢失,且你有已验证的手写文件 workaround。
    4. 怎么修复的:在 handleAdminRoute 里注册这条路由(放在 config 路由旁、安全门禁之下——自动继承与其他 /__bili 管理路径相同的 loopback + trusted-origin 门禁);顺手清掉同一重构遗留的死 import(独立标注 commit);新增一个经过真实代理/路由器的回归测试(startServer + port 0:畸形 body→400、保存→200 且不回显 key、store 文件落盘、config GET 反映状态、key:null 删除)。红绿验证过:不带修复跑是 404 失败,带上全绿。
    5. 是否有回归问题:审过的既有行为——其余 /__bili/* 路由逐条未动(纯新增一行注册,落在 404 兜底之前、门禁之后);server.ts 删的是整行死 import(9 个符号逐一 grep 确认无其他引用,typecheck 通过)。错误处理语义、默认值、时序、输出格式均无变化。未发现回归。
    6. 是否破坏缓存:不涉及——不触碰任何缓存/重试/游标/去重逻辑。
    7. 是否改了设计方向:没有——恢复的就是原设计的接线(handler/UI/测试本来都在),没有引入新机制。
    8. 是否引入了新的配置:没有——无新 env/config/默认值。

    行为变更声明:PUT /__bili/external-summary/credential 从「永远 404」变为可用端点(旧值→新值如上);安全姿态不变(loopback + origin 门禁与兄弟管理路径一致)。这是有意的修复目标,不是漂移。

    本地验证:typecheck 干净;定向套件 web-routing 9/9、external-summary-settings 43/43。全量回归以远程 CI 为准。判定:可合(等 CI 绿 + 人工合并)。合并后你重启 bili 即可直接在 UI 里 Save Key,不用再手写文件。

  3. ranxianglei commented on Oct 16, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    更正上一条里的一处笔误:PR #3445 正文写的是 Closes #3443(即本 issue),不是 Closes #3445。其余内容不变。

  4. k-ying commented on Nov 13, 2026

    @k-ying

    Still reproducible on 0.1.213 — the fix never shipped

    Environment: bili 0.1.213 (GET /__bili/health -> {"version":"0.1.213","commit":"133f3525c","diskVersion":"0.1.213"}); npm latest is also 0.1.213 at the time of writing.

    Repro (config page -> a recipe that uses credentialRef -> paste key -> Save Key):

    PUT /__bili/external-summary/credential
    
    404 {"error":{"type":"not_found","message":"no such management endpoint",
         "version":"0.1.213","commit":"133f3525c","diskVersion":"0.1.213","stale":false}}
    

    stale: false and diskVersion === version, so this is not a stale process. In 0.1.213 the /__bili dispatcher has 42 req.url === "..." comparisons and none of them is external-summary/credential, while the Web UI still ships the PUT call. The handler is simply not registered on the server side.

    Why it never landed: the fix PR #3445 (+70/-2, 2 commits) was closed unmerged on 2026-10-24 during a stale-ticket cleanup ("目标 issue #3443 已关 ... 如判断有误请直接 reopen 并留言"). #3488 then recorded this sub-item as "already fixed by PR #3445", which is not the case. So the patch never reached npm.

    Workaround until the route is registered: write the store by hand — <config-file>.summary-credentials.json (e.g. ~/.config/billion-context/billion-context.json.summary-credentials.json), content {"<credentialRef>":"<key>"}, mode 0600, regular file, no symlink. It is re-read on each request, no restart needed. Note that Save Key is the only broken piece: credentials resolve fine once the chain is enabled, and /__bili/config keeps externalSummaryCredentials empty while compress.externalSummary.enabled is false (targets are only expanded when enabled), so an empty list there does not mean the file was rejected.

    Would you consider reopening #3445, or re-registering the route? The change is self-contained: one PUT branch in the admin router that calls the existing SummaryCredentialStore.set().


    中文摘要

    0.1.213 上 PUT /__bili/external-summary/credential 仍然 404(no such management endpoint,stale:false,diskVersion 与 version 同为 0.1.213),服务端 42 条路由里没有这一条,前端却仍在调用。原修复 PR #3445 于 2026-10-24 被当作陈旧票关闭(未合并),#3488 又把它记成「已由 #3445 修复」,于是补丁始终没进 npm。

    临时绕过:手写 <配置文件>.summary-credentials.json(内容 {"<credentialRef>":"<key>"},0600,普通文件、非软链接),每次请求都会重新读取,无需重启。另注意 enabled:false 时 /__bili/config 的 externalSummaryCredentials 本来为空(不启用就不会展开 targets),不代表写入失败。

    能否重开 #3445 或重新注册该路由?改动很小,只需在 admin 路由加一个 PUT 分支调用现有的 SummaryCredentialStore.set()。

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions