Add Chinese and English localized messages and fix localize tenant limit errors - #3696
Add Chinese and English localized messages and fix localize tenant limit errors #3696Junqilee wants to merge 5 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| """Raised when a platform or tenant hard resource limit is reached.""" | ||
|
|
||
| pass | ||
| code = "TENANT_RESOURCE_LIMIT_REACHED" |
There was a problem hiding this comment.
TenantResourceLimitError 不再使用自定义字符串 "TENANT_RESOURCE_LIMIT_REACHED",改为使用 backend/consts/error_code.py 中已有的标准错误码:
ErrorCode.TENANT_RESOURCE_EXCEEDED.value # 120104
同时补充该错误码与 HTTP 429 的映射,并同步更新前端错误识别逻辑和相关测试。
| ? "blue" | ||
| : role === "ASSET_OWNER" | ||
| ? "gold" | ||
| : "gray"; |
There was a problem hiding this comment.
嵌套三元组可读性太差了,建议用字典维护
const ROLE_COLORS = {
SUPER_ADMIN: "magenta",
ADMIN: "purple",
DEV: "cyan",
USER: "blue",
ASSET_OWNER: "gold",
};
const color = ROLE_COLORS[role] || "gray";
There was a problem hiding this comment.
将 UserList.tsx 中的嵌套三元表达式替换为 ROLE_COLORS 字典:
'''
const ROLE_COLORS: Record<string, string> = {
SUPER_ADMIN: "magenta",
ADMIN: "purple",
DEV: "cyan",
USER: "blue",
ASSET_OWNER: "gold",
};
const color = ROLE_COLORS[role] || "gray";
'''
保持原有显示效果,同时提高可读性和后续扩展性。
| except TenantResourceLimitError as exc: | ||
| logger.warning(f"Tenant creation rejected by resource limit: {str(exc)}") | ||
| raise HTTPException( | ||
| status_code=HTTPStatus.BAD_REQUEST, |
There was a problem hiding this comment.
租户资源达到硬性上限属于配额限制,已将 tenant_app.py 中的:
HTTPStatus.BAD_REQUEST
修改为:
HTTPStatus.TOO_MANY_REQUESTS # 429
同时统一调整其他 TenantResourceLimitError 接口处理逻辑,并保留原有结构化错误信息和上限数据。相关测试已同步更新并通过。

Summary
messagefield, preventing client-side exceptions when the tenant user limit is reached.Validation