Skip to content

Add Chinese and English localized messages and fix localize tenant limit errors - #3696

Open
Junqilee wants to merge 5 commits into
ModelEngine-Group:developfrom
Junqilee:codex/tenant-limit-test-fix
Open

Add Chinese and English localized messages and fix localize tenant limit errors #3696
Junqilee wants to merge 5 commits into
ModelEngine-Group:developfrom
Junqilee:codex/tenant-limit-test-fix

Conversation

@Junqilee

Copy link
Copy Markdown
Contributor

Summary

  • Add Chinese and English localized messages for tenant, user, group, administrator, and super-administrator resource limits.
  • Normalize structured registration errors returned under the backend message field, preventing client-side exceptions when the tenant user limit is reached.
  • Automatically remove the Supabase Auth account when local tenant relationship creation fails, preventing orphan accounts.

Validation

  • Backend regression tests passed.
  • Frontend Docker build passed.
  • Chinese and English limit messages were manually verified.
租户上限提示 租户上限提示-英文

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread backend/consts/exceptions.py Outdated
"""Raised when a platform or tenant hard resource limit is reached."""

pass
code = "TENANT_RESOURCE_LIMIT_REACHED"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image 错误码定义是有标准的

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TenantResourceLimitError 不再使用自定义字符串 "TENANT_RESOURCE_LIMIT_REACHED",改为使用 backend/consts/error_code.py 中已有的标准错误码:
ErrorCode.TENANT_RESOURCE_EXCEEDED.value # 120104
同时补充该错误码与 HTTP 429 的映射,并同步更新前端错误识别逻辑和相关测试。

? "blue"
: role === "ASSET_OWNER"
? "gold"
: "gray";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嵌套三元组可读性太差了,建议用字典维护
const ROLE_COLORS = {
SUPER_ADMIN: "magenta",
ADMIN: "purple",
DEV: "cyan",
USER: "blue",
ASSET_OWNER: "gold",
};
const color = ROLE_COLORS[role] || "gray";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

将 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";
'''
保持原有显示效果,同时提高可读性和后续扩展性。

Comment thread backend/apps/tenant_app.py Outdated
except TenantResourceLimitError as exc:
logger.warning(f"Tenant creation rejected by resource limit: {str(exc)}")
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配额限制一般使用429错误码

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

租户资源达到硬性上限属于配额限制,已将 tenant_app.py 中的:
HTTPStatus.BAD_REQUEST
修改为:
HTTPStatus.TOO_MANY_REQUESTS # 429
同时统一调整其他 TenantResourceLimitError 接口处理逻辑,并保留原有结构化错误信息和上限数据。相关测试已同步更新并通过。

@Junqilee
Junqilee requested a review from jeffwu-1999 as a code owner August 19, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants