From 743b9278c4ab38ad9c4fdcc087aa597a836b4523 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sat, 7 Feb 2026 01:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix:=20billing=20sessio?= =?UTF-8?q?n=20error=20handling=20for=20subscription-first=20fallback.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligns the error variable types in the subscription-first path so that quota fallback checks use the correct NewAPIError. This prevents build failures and preserves the intended wallet fallback when subscription pre-consume returns an insufficient quota error. --- service/billing_session.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/service/billing_session.go b/service/billing_session.go index 00da526b..1a31316b 100644 --- a/service/billing_session.go +++ b/service/billing_session.go @@ -323,19 +323,19 @@ func NewBillingSession(c *gin.Context, relayInfo *relaycommon.RelayInfo, preCons case "subscription_first": fallthrough default: - hasSub, err := model.HasActiveUserSubscription(relayInfo.UserId) - if err != nil { - return nil, types.NewError(err, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry()) + hasSub, subCheckErr := model.HasActiveUserSubscription(relayInfo.UserId) + if subCheckErr != nil { + return nil, types.NewError(subCheckErr, types.ErrorCodeQueryDataError, types.ErrOptionWithSkipRetry()) } if !hasSub { return tryWallet() } - session, err := trySubscription() - if err != nil { - if err.GetErrorCode() == types.ErrorCodeInsufficientUserQuota { + session, apiErr := trySubscription() + if apiErr != nil { + if apiErr.GetErrorCode() == types.ErrorCodeInsufficientUserQuota { return tryWallet() } - return nil, err + return nil, apiErr } return session, nil }