Skip to content

Commit ce60857

Browse files
committed
fix: 移除标准分组Sort字段的错误范围限制
问题: - 标准分组编辑时修改排序值为5000提示错误"hub.model_pool.invalid_priority" - Sort字段被错误地限制在1-999范围内,导致用户无法设置较大的排序值 - 该限制是从Hub集中管理的priority字段错误复制过来的 根本原因: - Hub的priority字段(1-999有效,1000=禁用)与标准分组的Sort字段是完全不同的概念 - Sort字段仅用于分组列表的显示排序,不应有范围限制 - 通过git历史确认原始设计中Sort字段没有任何范围限制 修复内容: - 移除CreateGroup和UpdateGroup中对Sort字段的1-999范围验证 - 恢复Sort字段可接受任意整数值的原始行为 - 更新测试用例,验证5000等大值可正常使用 影响范围: - internal/services/group_service.go: 移除两处Sort字段验证逻辑 - internal/services/group_service_test.go: 更新测试用例验证大值场景 测试: - 所有单元测试通过 - 编译成功无警告 - go vet检查通过
1 parent 921054a commit ce60857

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

internal/services/group_service.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,6 @@ func (s *GroupService) CreateGroup(ctx context.Context, params GroupCreateParams
269269
params.Sort = 100
270270
}
271271

272-
// Validate Sort field: must be between 1 and 999
273-
// Priority >= 1000 is reserved for internal use (disabled state)
274-
if params.Sort < 1 || params.Sort > 999 {
275-
return nil, NewI18nError(app_errors.ErrValidation, "hub.model_pool.invalid_priority", nil)
276-
}
277-
278272
var cleanedUpstreams datatypes.JSON
279273
var testModel string
280274
var validationEndpoint string
@@ -764,11 +758,6 @@ func (s *GroupService) UpdateGroup(ctx context.Context, id uint, params GroupUpd
764758
}
765759

766760
if params.Sort != nil {
767-
// Validate Sort field: must be between 1 and 999
768-
// Priority >= 1000 is reserved for internal use (disabled state)
769-
if *params.Sort < 1 || *params.Sort > 999 {
770-
return nil, NewI18nError(app_errors.ErrValidation, "hub.model_pool.invalid_priority", nil)
771-
}
772761
group.Sort = *params.Sort
773762
}
774763

internal/services/group_service_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@ func TestCreateGroup(t *testing.T) {
171171
expectError: false,
172172
},
173173
{
174-
name: "invalid sort range",
174+
name: "valid high sort value",
175175
params: GroupCreateParams{
176-
Name: "invalid-sort",
176+
Name: "high-sort-group",
177177
GroupType: "standard",
178178
Upstreams: json.RawMessage(`[{"url":"https://api.openai.com","weight":100}]`),
179179
ChannelType: "openai",
180-
Sort: 1000,
180+
Sort: 5000, // Valid: no range limit on sort field
181181
TestModel: "gpt-3.5-turbo",
182182
ValidationEndpoint: "/v1/chat/completions",
183183
},
184-
expectError: true,
184+
expectError: false,
185185
},
186186
{
187187
name: "invalid group name",

0 commit comments

Comments
 (0)