From 3e13810ca2904604681d8fd54d91552d545bd0db Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Wed, 10 Jan 2024 00:17:03 +0800 Subject: [PATCH] fix: fix channel panic --- middleware/distributor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/middleware/distributor.go b/middleware/distributor.go index a70ed41..e2b8f2a 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -108,6 +108,10 @@ func Distribute() func(c *gin.Context) { abortWithMessage(c, http.StatusServiceUnavailable, message) return } + if channel == nil { + abortWithMessage(c, http.StatusServiceUnavailable, fmt.Sprintf("当前分组 %s 下对于模型 %s 无可用渠道(数据库一致性已被破坏)", userGroup, modelRequest.Model)) + return + } } c.Set("channel", channel.Type) c.Set("channel_id", channel.Id)