feat(ai-gateway): enforce gateway name prefixes - #3150
Merged
wklken merged 4 commits intoAug 11, 2026
Conversation
Require new AI gateways to use the bkai- prefix and reserve that prefix from non-AI gateways. Allow bkaidev and bkaidev-* only when V1 or V2 automated sync creates an AI gateway, while preserving updates to existing gateways. Document the naming contract and cover Web, sync serializers, saver behavior, official gateways, and compatibility cases.
Use bkai-demo consistently in the V1 and V2 sync response examples so they match the request path and returned gateway name.
Allow the internal bkaidev name convention across Web, V1/V2 sync, and direct Saver creation through one shared validator. Remove the source-specific flag and keep public API documentation and error messages focused on the bkai- naming rule.
wklken
commented
Aug 11, 2026
wklken
left a comment
Collaborator
Author
There was a problem hiding this comment.
PR #3150 合并 Review 报告(Codex + Claude 双模型汇总)
仓库: TencentBlueKing/blueking-apigateway
PR: feat(ai-gateway): enforce gateway name prefixes (#3150)
作者: wklken | 分支: feat/ai-gateway-name-prefix → master
审查 commit: a9361f63809b21c3ed99e2276162535be0336260
模型: Codex (gpt-5.6-sol) + Claude Opus 5 [1m]
合并建议
merge after fixes — 两个模型一致认为改动方向正确、兜底点选得对(GatewaySaver._create_gateway 覆盖全部创建入口)、测试与文档同步到位,无 Critical 缺陷。但存在「意图与实现不吻合」类问题需合并前确认。
双模型一致关注点
High Issues(建议合并前修复)
H1. bkaidev* 未从非 AI 网关侧保留 → 自动化同步名可被永久抢占
- 位置:
service/gateway_name.py:29-34、相关 sync 测试 kind != AI分支只拦bkai-前缀,对bkaidev/bkaidev-*完全放行。网关名全局唯一,若任何用户先建名为bkaidev的普通网关,V1/V2 自动化同步再建同名 AI 网关会永久失败——而这恰是本 PR 开的豁免口子。- 建议:将
bkaidev/bkaidev-一并纳入「仅 AI 可用」保留前缀集合,或明确注释说明为何允许被占用。
H2. allow_bkaidev_ai_name 在 sync 入口硬编码 True,与「仅自动化同步」描述不符
- 位置:
biz/gateway/gateway.py:285、apis/open/gateway/serializers.py:178、apis/v2/sync/serializers.py:180 sync_gateway()对所有 openapi 同步请求无条件传True,未按app_code区分,实现等价于「任何有 sync 权限的应用都能创建bkaidev*AI 网关」。文档也写成了对所有调用方公开的规则,与「专用名称」表述矛盾。- 建议:若只允特定应用,加
bk_app_code白名单;若接受所有 sync 调用方,修正 PR 描述与文档措辞。
Medium Issues
- M1(字面值泛滥/设计偏差):
"bkai-"、"bkaidev"直接硬编码进新模块(共 6 处),未复用既有settings.OFFICIAL_GATEWAY_NAME_PREFIXES/RESERVED_GATEWAY_NAME_PREFIXES机制。 - M2:sync SLZ 与
GatewaySaver双重校验存在冗余(Codex 认为属合理纵深保护,Claude 列为可后续清理)。 - M3(i18n):
service/gateway_name.py三条新错误为裸中文字符串,绕过项目gettext机制,非中文环境固定显示中文。 - M4(代码组织):纯字符串校验器落在
service/而非更通用的common/。
Low Issues
- Django Admin 创建路径未接入新命名约束(
GatewayAdmin可绕过),属历史创建边界未被新不变量覆盖(Codex 提出)。 - 错误文案未国际化(M3 同)。
双方一致认可(Dismissed / 合理设计)
- 已有网关更新跳过新命名规则:create/update 已正确区分,与历史兼容一致。
- 重复校验属合理纵深保护(覆盖 management command 等非 HTTP 入口)。
- 无 Critical 缺陷,无会导致崩溃或数据损坏的问题。
[from openclaw-internal]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
bkai-prefixbkai-from non-AI gateway creationbkaidevandbkaidev-*only when V1/V2 automated sync creates an AI gatewayChecklist
Verification:
uv run make lint-checkuv run make test(3807 passed)