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

1.2 KiB
Raw Blame History

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.pyStarletteHTTPException handler 调用 translate_http_detail
  • tests/test_http_errors_zh.py

迁移 / 重启

需重启 API / 重建镜像。

验证

pytest tests/test_http_errors_zh.py tests/test_validation_errors_zh.py -q
# 示例:GET /api/servers/999999 → detail「服务器不存在」

后续(同批追加)

  • auth.py / auth_jwt.pyfallback 与字面量改中文;auth_failure_detail() 映射 reason 码(避免返回 admin_not_found
  • auth_service.pysetup_totp / enable_totp 失败路径补 message

仍待

  • 其它模块 str(exc) 透传
  • 非 auth 路由字面量可逐步改源码或补 _DETAIL_EXACT