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
9905599d
authored
Mar 06, 2026
by
Calcium-Ion
Committed by
GitHub
Mar 06, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3151 from seefs001/feature/bad-responses-body-no-retry
fix(relay): skip retries for bad response body errors
parents
ffb06d08
329416d6
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 @
9905599d
...
@@ -341,6 +341,9 @@ func shouldRetry(c *gin.Context, openaiErr *types.NewAPIError, retryTimes int) b
...
@@ -341,6 +341,9 @@ func shouldRetry(c *gin.Context, openaiErr *types.NewAPIError, retryTimes int) b
if
code
<
100
||
code
>
599
{
if
code
<
100
||
code
>
599
{
return
true
return
true
}
}
if
operation_setting
.
IsAlwaysSkipRetryCode
(
openaiErr
.
GetErrorCode
())
{
return
false
}
return
operation_setting
.
ShouldRetryByStatusCode
(
code
)
return
operation_setting
.
ShouldRetryByStatusCode
(
code
)
}
}
...
...
setting/operation_setting/status_code_ranges.go
View file @
9905599d
...
@@ -5,6 +5,8 @@ import (
...
@@ -5,6 +5,8 @@ import (
"sort"
"sort"
"strconv"
"strconv"
"strings"
"strings"
"github.com/QuantumNous/new-api/types"
)
)
type
StatusCodeRange
struct
{
type
StatusCodeRange
struct
{
...
@@ -31,6 +33,10 @@ var alwaysSkipRetryStatusCodes = map[int]struct{}{
...
@@ -31,6 +33,10 @@ var alwaysSkipRetryStatusCodes = map[int]struct{}{
524
:
{},
524
:
{},
}
}
var
alwaysSkipRetryCodes
=
map
[
types
.
ErrorCode
]
struct
{}{
types
.
ErrorCodeBadResponseBody
:
{},
}
func
AutomaticDisableStatusCodesToString
()
string
{
func
AutomaticDisableStatusCodesToString
()
string
{
return
statusCodeRangesToString
(
AutomaticDisableStatusCodeRanges
)
return
statusCodeRangesToString
(
AutomaticDisableStatusCodeRanges
)
}
}
...
@@ -66,6 +72,11 @@ func IsAlwaysSkipRetryStatusCode(code int) bool {
...
@@ -66,6 +72,11 @@ func IsAlwaysSkipRetryStatusCode(code int) bool {
return
exists
return
exists
}
}
func
IsAlwaysSkipRetryCode
(
errorCode
types
.
ErrorCode
)
bool
{
_
,
exists
:=
alwaysSkipRetryCodes
[
errorCode
]
return
exists
}
func
ShouldRetryByStatusCode
(
code
int
)
bool
{
func
ShouldRetryByStatusCode
(
code
int
)
bool
{
if
IsAlwaysSkipRetryStatusCode
(
code
)
{
if
IsAlwaysSkipRetryStatusCode
(
code
)
{
return
false
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