Skip to content

Commit 8a650fb

Browse files
authored
Merge pull request #113 from xunxun1982/xxdev
fix: 移除标准分组Sort字段的错误范围限制
2 parents 0474269 + ce60857 commit 8a650fb

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)