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
7d26b810
Commit
7d26b810
authored
Mar 18, 2026
by
alfadb
Browse files
fix: address review - add missing whitespace patterns and narrow error matching
parent
b8ada63a
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/gateway_request.go
View file @
7d26b810
...
@@ -32,6 +32,8 @@ var (
...
@@ -32,6 +32,8 @@ var (
// Fast-path patterns for empty text blocks: {"type":"text","text":""}
// Fast-path patterns for empty text blocks: {"type":"text","text":""}
patternEmptyText
=
[]
byte
(
`"text":""`
)
patternEmptyText
=
[]
byte
(
`"text":""`
)
patternEmptyTextSpaced
=
[]
byte
(
`"text": ""`
)
patternEmptyTextSpaced
=
[]
byte
(
`"text": ""`
)
patternEmptyTextSp1
=
[]
byte
(
`"text" : ""`
)
patternEmptyTextSp2
=
[]
byte
(
`"text" :""`
)
)
)
// SessionContext 粘性会话上下文,用于区分不同来源的请求。
// SessionContext 粘性会话上下文,用于区分不同来源的请求。
...
@@ -247,7 +249,9 @@ func FilterThinkingBlocksForRetry(body []byte) []byte {
...
@@ -247,7 +249,9 @@ func FilterThinkingBlocksForRetry(body []byte) []byte {
// Check for empty text blocks: {"type":"text","text":""}
// Check for empty text blocks: {"type":"text","text":""}
// These cause upstream 400: "text content blocks must be non-empty"
// These cause upstream 400: "text content blocks must be non-empty"
hasEmptyTextBlock
:=
bytes
.
Contains
(
body
,
patternEmptyText
)
||
hasEmptyTextBlock
:=
bytes
.
Contains
(
body
,
patternEmptyText
)
||
bytes
.
Contains
(
body
,
patternEmptyTextSpaced
)
bytes
.
Contains
(
body
,
patternEmptyTextSpaced
)
||
bytes
.
Contains
(
body
,
patternEmptyTextSp1
)
||
bytes
.
Contains
(
body
,
patternEmptyTextSp2
)
// Fast path: nothing to process
// Fast path: nothing to process
if
!
hasThinkingContent
&&
!
hasEmptyContent
&&
!
hasEmptyTextBlock
{
if
!
hasThinkingContent
&&
!
hasEmptyContent
&&
!
hasEmptyTextBlock
{
...
...
backend/internal/service/gateway_service.go
View file @
7d26b810
...
@@ -6071,7 +6071,7 @@ func (s *GatewayService) isThinkingBlockSignatureError(respBody []byte) bool {
...
@@ -6071,7 +6071,7 @@ func (s *GatewayService) isThinkingBlockSignatureError(respBody []byte) bool {
// 例如: "all messages must have non-empty content"
// 例如: "all messages must have non-empty content"
// "messages: text content blocks must be non-empty"
// "messages: text content blocks must be non-empty"
if
strings
.
Contains
(
msg
,
"non-empty content"
)
||
strings
.
Contains
(
msg
,
"empty content"
)
||
if
strings
.
Contains
(
msg
,
"non-empty content"
)
||
strings
.
Contains
(
msg
,
"empty content"
)
||
strings
.
Contains
(
msg
,
"must be non-empty"
)
{
strings
.
Contains
(
msg
,
"
content blocks
must be non-empty"
)
{
logger
.
LegacyPrintf
(
"service.gateway"
,
"[SignatureCheck] Detected empty content error"
)
logger
.
LegacyPrintf
(
"service.gateway"
,
"[SignatureCheck] Detected empty content error"
)
return
true
return
true
}
}
...
...
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