fix(gateway): 修复批量更新 API 格式时的认证通道状态冲突 - #702
Merged
fawney19 merged 1 commit intoJul 31, 2026
Merged
Conversation
MMEXA
force-pushed
the
fix/reconcile-auth-channel-mismatch-formats
branch
from
July 30, 2026 13:56
9adcd1b to
b738bbc
Compare
MMEXA
force-pushed
the
fix/reconcile-auth-channel-mismatch-formats
branch
from
July 30, 2026 14:14
b738bbc to
6ecfe0f
Compare
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.
问题背景
管理员在号池批量编辑中修改
api_formats时,客户端只提交本次实际编辑的字段,不会重复提交隐藏的allow_auth_channel_mismatch_formats。旧数据中如果仍保留已不属于新格式集合的值,更新构建器会把这份历史状态当作显式输入再次严格校验,导致整个批量操作返回 400,例如:allow_auth_channel_mismatch_formats 包含未选择的 API 格式: openai:embedding这会阻断本应合法的格式收窄操作,并且要求调用方了解和修复其未编辑的内部状态。
根因
密钥更新主链没有区分两种不同语义:
allow_auth_channel_mismatch_formats,此时必须严格验证其为已选 API 格式的子集;api_formats,此时历史 allowlist 属于待协调的既有状态,应随新的格式集合确定性收敛。原实现对两种情况都调用严格校验,因此历史残留会把正常更新转换为配置错误。
修改内容
api_formats且省略 mismatch 字段时,将历史 allowlist 与新的格式集合取交集;api_formats推导完整集合,因此保留其 allowlist,不按空集合误删;行为契约
api_formatsCI 稳定性
PR 首轮与重触发后的
Test (Workspace Rest)都在同一条 usage runtime 并发测试中触发 2 秒超时。该测试使用Notify::notify_waiters()释放单个生命周期等待者;如果通知发生在等待 future 真正注册之前,通知不会保留 permit,测试会永久等待到超时。本次同步修正不改变生产代码:
notify_one();验证
cargo fmt --all -- --checkcargo clippy -p aether-gateway --lib --bins --examples -- -D warningscargo clippy -p aether-usage-runtime --all-targets -- -D warningsRUST_MIN_STACK=16777216 cargo nextest run -p aether-gateway --lib -E 'test(gateway_batch_updates_shared_pool_key_configuration) | test(gateway_preserves_inherited_fixed_oauth_mismatch_formats_on_batch_update) | test(gateway_rejects_explicit_invalid_mismatch_format_without_writing_any_key) | test(reconcile_allow_auth_channel_mismatch_formats_keeps_only_selected_formats)' --no-fail-fastcargo nextest run -p aether-usage-runtime -E 'test(awaited_terminal_does_not_hold_permit_behind_queued_terminal_seed) | test(submitted_terminal_does_not_hold_permit_behind_queued_terminal_seed)' --no-fail-fast聚焦结果:gateway 4 个测试与 usage runtime 2 个测试全部通过。覆盖普通密钥的交集收敛与空交集、显式非法配置的错误文本和零写入、固定 OAuth Provider 的继承格式保留,以及两种 terminal 提交模式下的确定性并发排队与完整持久化。