fix(settings): 保存设置时将数值字段转为字符串避免 422

SettingUpdatePayload.value 要求 str,连接池与告警阈值为 number 输入。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nexus Agent
2026-06-08 14:50:10 +08:00
parent 85ecd1f54f
commit ff143c286d
3 changed files with 46 additions and 1 deletions
@@ -0,0 +1,22 @@
# 审计 — 设置页连接池保存
**Changelog**: `docs/changelog/2026-06-08-settings-pool-size-string-payload.md`
## 变更文件
`SettingsPage.vue`
## Step 3
| 项 | 结论 |
|----|------|
| value 转 String | PASS |
| 与 SettingUpdatePayload str 一致 | PASS |
## Closure
Gate 7/7 PASS · 生产部署 · `/health` 200
## DoD
- [x] 连接池/阈值保存无 422 string_type
@@ -0,0 +1,23 @@
# 设置页连接池保存校验修复
**日期**2026-06-08
## 变更摘要
修复设置页保存「连接池大小 / 溢出连接数」时报 `value: Input should be a valid string` 的问题。
## 动机
`db_pool_size``db_max_overflow` 及告警阈值在表单中为 `number``saveSettings` 原样 PUT JSON 数字;后端 `SettingUpdatePayload.value` 类型为 `str`Pydantic 422。
## 涉及文件
- `frontend/src/pages/SettingsPage.vue` — 保存时 `String(value ?? '')`
## 迁移 / 重启
无。前端构建部署即可。
## 验证
设置页修改连接池 → 保存 → 应成功 toast,无 422。
+1 -1
View File
@@ -568,7 +568,7 @@ async function saveSettings() {
['system_name', 'system_title', 'cpu_alert_threshold', 'mem_alert_threshold', 'disk_alert_threshold', 'db_pool_size', 'db_max_overflow'].includes(key)
)
for (const [key, value] of entries) {
await http.put(`/settings/${key}`, { value })
await http.put(`/settings/${key}`, { value: String(value ?? '') })
}
snackbar('设置已保存')
} catch (e: unknown) {