Conversation
* feat: 支持分组级故障转移状态码(增量) * fix: 限制故障转移状态码为分组级配置
- 新增 validateStringSettingValue 辅助函数,消除 ValidateGroupConfigOverrides 中的重复校验逻辑 - 删除 ValidateSettings 中已成死代码的 failover_status_codes 分支(上游 ValidateSystemSettingsPayload 已拦截) - 统一使用 GroupScopedSettingKeyFailoverStatusCodes 常量,消除字符串字面量
- 将 failover_status_codes 回归"系统默认 + 分组覆盖"标准模式 - 添加 default:"400-403,405-999",与原硬编码行为等价 - EnsureSettingsInitialized 不再跳过该字段,升级后自动写入默认值 - GetSettings 不再 sanitize,系统设置页可见可改 - proxy 层改为纯 matcher 匹配,删除硬编码默认条件 - shouldFailoverOnStatusCode 直接读 group.FailoverStatusCodeMatcher - 字段语义从"追加"变为"完整策略",名字与行为对齐 - 删除特殊化机制:sanitizeRuntimeSystemSettings、IsSystemSettingVisible、 ValidateSystemSettingsPayload 及所有调用点 - ValidateSettings 补充 failover_status_codes 格式校验,与分组校验一致 - 更新三语 i18n 文案,示例改为 400-403,405-999,250-260 升级兼容:未配置用户行为完全不变;配置过分组级该字段的用户 需将旧的"追加"写法改为"完整列表"写法
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1ca9ff71f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
关联 Issue / Related Issue
基于 #397 代码审查后的重构,解决设计不一致问题。
变更内容 / Change Content
问题
#397 引入的
failover_status_codes存在两处设计缺陷:配置模式不一致:项目其他可覆盖字段(
max_retries、blacklist_threshold等)均遵循"系统全局默认 + 分组覆盖"标准模式,而failover_status_codes被特殊处理为"仅分组级",通过 sanitize / visibility / payload validation 三套机制强制隐藏系统级入口,带来约 50 行冗余代码。字段语义与名字错位:原实现为 OR 叠加语义(分组配置叠加在硬编码默认条件之上),导致单独配置
429完全无效(默认条件>=400 except 404已覆盖),字段名"故障转移状态码"与"追加状态码"的实际行为不符。改动
types.go:添加default:"400-403,405-999",将原硬编码的默认行为显式化system_settings.go:删除sanitizeRuntimeSystemSettings、IsSystemSettingVisible、ValidateSystemSettingsPayload三套特殊化机制及所有调用点;ValidateSettings补充failover_status_codes格式校验settings_handler.go:删除可见性过滤循环和 payload 拒绝逻辑proxy/server.go:shouldFailoverOnStatusCode改为纯 matcher 匹配,删除硬编码>=400 except 404条件升级兼容说明
EnsureSettingsInitialized启动时自动写入默认值400-403,405-999,行为与升级前完全等价,无感知。failover_status_codes的用户(v1.4.7 新字段,极少数):语义从"追加"变为"完整列表",需将旧配置改为完整表达式,例如原来配404需改为400-599。自查清单 / Checklist
go build ./...