Files
Nexus/docs/changelog/2026-06-09-http-api-detail-zh.md
T
Nexus Agent 3ba78cd10a feat(api): translate HTTPException detail to Chinese for admin routes
Add a global detail translator for common 4xx messages (Server not found,
auth headers, settings not found, etc.) while keeping /api/agent/* in English.

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

995 B
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「服务器不存在」

后续

  • 新增英文字面量时补 _DETAIL_EXACT 或改源码直接写中文
  • str(exc) 透传类错误依赖下层异常已是中文