From 2fa5deb916252d1ee1dc5276141fab2e3949b9ad Mon Sep 17 00:00:00 2001 From: creamlike1024 Date: Fri, 7 Nov 2025 16:27:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(channel):=20=E5=BD=93=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E5=AF=86=E9=92=A5=E6=97=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=80=8C=E4=B8=8D=E6=98=AF=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=AF=86=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/channel.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/model/channel.go b/model/channel.go index 1dccaf2f..a5a247f3 100644 --- a/model/channel.go +++ b/model/channel.go @@ -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 {