mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 04:22:58 +00:00
fix(channel): 当没有可用密钥时返回错误而不是第一个密钥
This commit is contained in:
@@ -138,9 +138,11 @@ func (channel *Channel) GetNextEnabledKey() (string, int, *types.NewAPIError) {
|
||||
enabledIdx = append(enabledIdx, i)
|
||||
}
|
||||
}
|
||||
// If no specific status list or none enabled, fall back to first key
|
||||
// If no specific status list or none enabled, return an explicit error so caller can
|
||||
// properly handle a channel with no available keys (e.g. mark channel disabled).
|
||||
// Returning the first key here caused requests to keep using an already-disabled key.
|
||||
if len(enabledIdx) == 0 {
|
||||
return keys[0], 0, nil
|
||||
return "", 0, types.NewError(errors.New("no enabled keys"), types.ErrorCodeChannelNoAvailableKey)
|
||||
}
|
||||
|
||||
switch channel.ChannelInfo.MultiKeyMode {
|
||||
|
||||
Reference in New Issue
Block a user