Files
Nexus/docs/changelog/2026-06-09-http-api-detail-zh.md
T
Nexus Agent a842af2405 fix(auth): use Chinese fallbacks and map reason codes to user messages
Stop exposing raw reason codes like admin_not_found in TOTP setup errors;
auth routes and JWT guard now use Chinese literals with auth_failure_detail.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 08:44:51 +08:00

37 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-06-09 — HTTP API detail 英文改中文(全局层)
## 变更摘要
管理端 API 的 `HTTPException.detail` 经全局 handler 译为中文;`/api/agent/*` 保持英文(Agent 协议兼容)。
## 动机
Backlog「~75 条 API detail 英文」:422 已由 `validation_errors_zh.py` 覆盖,但 400/401/404 等仍返回 `Server not found` 等英文字面量。
## 涉及文件
- `server/utils/http_errors_zh.py`(新)— 精确映射 + 正则(如 immutable setting、command exit
- `server/main.py``StarletteHTTPException` handler 调用 `translate_http_detail`
- `tests/test_http_errors_zh.py`
## 迁移 / 重启
需重启 API / 重建镜像。
## 验证
```bash
pytest tests/test_http_errors_zh.py tests/test_validation_errors_zh.py -q
# 示例:GET /api/servers/999999 → detail「服务器不存在」
```
## 后续(同批追加)
- `auth.py` / `auth_jwt.py`fallback 与字面量改中文;`auth_failure_detail()` 映射 `reason` 码(避免返回 `admin_not_found`
- `auth_service.py``setup_totp` / `enable_totp` 失败路径补 `message`
## 仍待
- 其它模块 `str(exc)` 透传
- 非 auth 路由字面量可逐步改源码或补 `_DETAIL_EXACT`