Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
0f4dd972
Commit
0f4dd972
authored
Dec 31, 2025
by
shaw
Browse files
Merge branch 'tyqy12/main'
parents
db876ba7
b18f5f8c
Changes
2
Show whitespace changes
Inline
Side-by-side
backend/internal/service/openai_gateway_service.go
View file @
0f4dd972
...
@@ -240,7 +240,7 @@ func (s *OpenAIGatewayService) GetAccessToken(ctx context.Context, account *Acco
...
@@ -240,7 +240,7 @@ func (s *OpenAIGatewayService) GetAccessToken(ctx context.Context, account *Acco
func
(
s
*
OpenAIGatewayService
)
shouldFailoverUpstreamError
(
statusCode
int
)
bool
{
func
(
s
*
OpenAIGatewayService
)
shouldFailoverUpstreamError
(
statusCode
int
)
bool
{
switch
statusCode
{
switch
statusCode
{
case
401
,
403
,
429
,
529
:
case
401
,
402
,
403
,
429
,
529
:
return
true
return
true
default
:
default
:
return
statusCode
>=
500
return
statusCode
>=
500
...
@@ -454,6 +454,10 @@ func (s *OpenAIGatewayService) handleErrorResponse(ctx context.Context, resp *ht
...
@@ -454,6 +454,10 @@ func (s *OpenAIGatewayService) handleErrorResponse(ctx context.Context, resp *ht
statusCode
=
http
.
StatusBadGateway
statusCode
=
http
.
StatusBadGateway
errType
=
"upstream_error"
errType
=
"upstream_error"
errMsg
=
"Upstream authentication failed, please contact administrator"
errMsg
=
"Upstream authentication failed, please contact administrator"
case
402
:
statusCode
=
http
.
StatusBadGateway
errType
=
"upstream_error"
errMsg
=
"Upstream payment required: insufficient balance or billing issue"
case
403
:
case
403
:
statusCode
=
http
.
StatusBadGateway
statusCode
=
http
.
StatusBadGateway
errType
=
"upstream_error"
errType
=
"upstream_error"
...
...
backend/internal/service/ratelimit_service.go
View file @
0f4dd972
...
@@ -39,6 +39,10 @@ func (s *RateLimitService) HandleUpstreamError(ctx context.Context, account *Acc
...
@@ -39,6 +39,10 @@ func (s *RateLimitService) HandleUpstreamError(ctx context.Context, account *Acc
// 认证失败:停止调度,记录错误
// 认证失败:停止调度,记录错误
s
.
handleAuthError
(
ctx
,
account
,
"Authentication failed (401): invalid or expired credentials"
)
s
.
handleAuthError
(
ctx
,
account
,
"Authentication failed (401): invalid or expired credentials"
)
return
true
return
true
case
402
:
// 支付要求:余额不足或计费问题,停止调度
s
.
handleAuthError
(
ctx
,
account
,
"Payment required (402): insufficient balance or billing issue"
)
return
true
case
403
:
case
403
:
// 禁止访问:停止调度,记录错误
// 禁止访问:停止调度,记录错误
s
.
handleAuthError
(
ctx
,
account
,
"Access forbidden (403): account may be suspended or lack permissions"
)
s
.
handleAuthError
(
ctx
,
account
,
"Access forbidden (403): account may be suspended or lack permissions"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment