Expand dotted setting keys and mask secret pools #61

Merged
weichen merged 2 commits from fix/settings-dotted-keys into main 2026-10-04 13:43:05 +00:00
Owner

合同

PUT /api/settings/user 与 PUT /api/settings/project/{id} 同时接受嵌套对象和点路径键。点路径在写入时展开成嵌套。同一请求或已落库数据里两种形态并存时,嵌套对象胜出。

GET /api/settings 对 schema 中 type=secret 或 secret=true 的路径,以及叶子名 apiKey / api_key / apiKeys / secret / token,非空字符串一律返回 ••••••。写回恰好是这个占位符的叶子视为未修改,不覆盖已存密钥。

启动时在注册 Tavily 工具之前把已落库的点路径键展开。有迁移时日志为 settings: normalized N dotted key(s) in M scope(s)。存量值恰好是掩码占位符时只记录路径,不记录值,原值保留。

兼容

以前静默失效的点路径写入,升级后会生效。与嵌套对象冲突时,已生效的嵌套值保持不变。不按 schema 校验键名。不改 Core,不改前端。

验收

  • go test ./...(Backend d90b9c0)
  • 点路径写入后 Effective 能读到;GET 不回密钥明文;写回掩码不覆盖已存密钥

非目标

不改 svc.sh 播种时序。不修小队路径 tool.result 恒为 ok。

## 合同 `PUT /api/settings/user` 与 `PUT /api/settings/project/{id}` 同时接受嵌套对象和点路径键。点路径在写入时展开成嵌套。同一请求或已落库数据里两种形态并存时,嵌套对象胜出。 `GET /api/settings` 对 schema 中 `type=secret` 或 `secret=true` 的路径,以及叶子名 `apiKey` / `api_key` / `apiKeys` / `secret` / `token`,非空字符串一律返回 `••••••`。写回恰好是这个占位符的叶子视为未修改,不覆盖已存密钥。 启动时在注册 Tavily 工具之前把已落库的点路径键展开。有迁移时日志为 `settings: normalized N dotted key(s) in M scope(s)`。存量值恰好是掩码占位符时只记录路径,不记录值,原值保留。 ## 兼容 以前静默失效的点路径写入,升级后会生效。与嵌套对象冲突时,已生效的嵌套值保持不变。不按 schema 校验键名。不改 Core,不改前端。 ## 验收 - `go test ./...`(Backend `d90b9c0`) - 点路径写入后 `Effective` 能读到;GET 不回密钥明文;写回掩码不覆盖已存密钥 ## 非目标 不改 svc.sh 播种时序。不修小队路径 tool.result 恒为 ok。
weichen added 1 commit 2026-10-04 13:03:00 +00:00
Expand dotted setting keys and mask secret pools
ci / vet-and-test (pull_request) Successful in 52s
d90b9c045b
Why: A dotted-key PUT was stored beside the nested object and never read, so replacing a key kept the old pool. GET also returned tools.tavily.apiKeys in clear text, and saving settings would write the mask placeholder back over a real key.
Evidence: go test ./...
Impact: Dotted writes take effect on the next read. Startup expands stored dotted keys, and the existing nested value wins when both forms exist. GET masks schema secrets, including apiKeys. Writing the mask placeholder no longer overwrites a stored secret.
Refs: fix/settings-dotted-keys
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen added 1 commit 2026-10-04 13:42:40 +00:00
weichen merged commit fd17011047 into main 2026-10-04 13:43:05 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#61