fix(btpanel): login-url 返回类型含 bool 导致全站 500

路由注解 dict[str,str] 与 bootstrapped 布尔字段冲突,FastAPI 响应校验失败。
This commit is contained in:
r
2026-06-21 12:17:16 +08:00
parent 37720c4705
commit 629d8b3e26
4 changed files with 18 additions and 1 deletions
@@ -36,6 +36,8 @@
- `frontend/src/pages/btpanel/BtPanelMonitorPage.vue`
- `tests/test_btpanel_login_url.py`
- `tests/test_btpanel_client.py`
- `tests/test_btpanel_login_url_route.py`
- `server/api/btpanel.py`
- `docs/changelog/2026-06-21-btpanel-login-auto-bootstrap.md`
## DoD
@@ -31,3 +31,8 @@ cd frontend && npx vite build
```
生产:对未配置宝塔 API 的子机点「一键登录」,应自动获取后打开面板;审计 `bt_panel_login_url` 的 detail 含 `bootstrapped: true`
## 2026-06-21 热修
- **根因**`login-url` 路由返回类型 `dict[str, str]`,响应含 `bootstrapped: bool` → FastAPI 校验 500
- **修复**`server/api/btpanel.py` 改为 `dict[str, Any]`
+1 -1
View File
@@ -165,7 +165,7 @@ async def create_bt_login_url(
request: Request,
db: AsyncSession = Depends(get_db),
admin: Admin = Depends(get_current_admin),
) -> dict[str, str]:
) -> dict[str, Any]:
try:
return await _svc(db).create_login_url(
server_id,
+10
View File
@@ -0,0 +1,10 @@
"""Regression: login-url must not use dict[str, str] (bootstrapped is bool)."""
from typing import Any, get_type_hints
from server.api.btpanel import create_bt_login_url
def test_login_url_route_return_type_allows_bool_fields():
hints = get_type_hints(create_bt_login_url)
assert hints["return"] == dict[str, Any]