From e2429f20f86c234fa2d36077d527d561921df356 Mon Sep 17 00:00:00 2001 From: CaIon Date: Fri, 1 Aug 2025 18:09:20 +0800 Subject: [PATCH] fix: ensure ChannelIsMultiKey context key is set to false for single key retries --- middleware/distributor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/middleware/distributor.go b/middleware/distributor.go index fb4a6645..c7a55f4c 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -269,6 +269,9 @@ func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, mode if channel.ChannelInfo.IsMultiKey { common.SetContextKey(c, constant.ContextKeyChannelIsMultiKey, true) common.SetContextKey(c, constant.ContextKeyChannelMultiKeyIndex, index) + } else { + // 必须设置为 false,否则在重试到单个 key 的时候会导致日志显示错误 + common.SetContextKey(c, constant.ContextKeyChannelIsMultiKey, false) } // c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", key)) common.SetContextKey(c, constant.ContextKeyChannelKey, key)