Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
329416d6
authored
Mar 06, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(relay): skip retries for bad response body errors
parent
57d52586
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
controller/relay.go
+3
-0
setting/operation_setting/status_code_ranges.go
+11
-0
No files found.
controller/relay.go
View file @
329416d6
...
...
@@ -341,6 +341,9 @@ func shouldRetry(c *gin.Context, openaiErr *types.NewAPIError, retryTimes int) b
if
code
<
100
||
code
>
599
{
return
true
}
if
operation_setting
.
IsAlwaysSkipRetryCode
(
openaiErr
.
GetErrorCode
())
{
return
false
}
return
operation_setting
.
ShouldRetryByStatusCode
(
code
)
}
...
...
setting/operation_setting/status_code_ranges.go
View file @
329416d6
...
...
@@ -5,6 +5,8 @@ import (
"sort"
"strconv"
"strings"
"github.com/QuantumNous/new-api/types"
)
type
StatusCodeRange
struct
{
...
...
@@ -31,6 +33,10 @@ var alwaysSkipRetryStatusCodes = map[int]struct{}{
524
:
{},
}
var
alwaysSkipRetryCodes
=
map
[
types
.
ErrorCode
]
struct
{}{
types
.
ErrorCodeBadResponseBody
:
{},
}
func
AutomaticDisableStatusCodesToString
()
string
{
return
statusCodeRangesToString
(
AutomaticDisableStatusCodeRanges
)
}
...
...
@@ -66,6 +72,11 @@ func IsAlwaysSkipRetryStatusCode(code int) bool {
return
exists
}
func
IsAlwaysSkipRetryCode
(
errorCode
types
.
ErrorCode
)
bool
{
_
,
exists
:=
alwaysSkipRetryCodes
[
errorCode
]
return
exists
}
func
ShouldRetryByStatusCode
(
code
int
)
bool
{
if
IsAlwaysSkipRetryStatusCode
(
code
)
{
return
false
...
...
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