Skip to content

Commit 7d26b81

Browse files
committed
fix: address review - add missing whitespace patterns and narrow error matching
1 parent b8ada63 commit 7d26b81

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

backend/internal/service/gateway_request.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var (
3232
// Fast-path patterns for empty text blocks: {"type":"text","text":""}
3333
patternEmptyText = []byte(`"text":""`)
3434
patternEmptyTextSpaced = []byte(`"text": ""`)
35+
patternEmptyTextSp1 = []byte(`"text" : ""`)
36+
patternEmptyTextSp2 = []byte(`"text" :""`)
3537
)
3638

3739
// SessionContext 粘性会话上下文,用于区分不同来源的请求。
@@ -247,7 +249,9 @@ func FilterThinkingBlocksForRetry(body []byte) []byte {
247249
// Check for empty text blocks: {"type":"text","text":""}
248250
// These cause upstream 400: "text content blocks must be non-empty"
249251
hasEmptyTextBlock := bytes.Contains(body, patternEmptyText) ||
250-
bytes.Contains(body, patternEmptyTextSpaced)
252+
bytes.Contains(body, patternEmptyTextSpaced) ||
253+
bytes.Contains(body, patternEmptyTextSp1) ||
254+
bytes.Contains(body, patternEmptyTextSp2)
251255

252256
// Fast path: nothing to process
253257
if !hasThinkingContent && !hasEmptyContent && !hasEmptyTextBlock {

backend/internal/service/gateway_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6071,7 +6071,7 @@ func (s *GatewayService) isThinkingBlockSignatureError(respBody []byte) bool {
60716071
// 例如: "all messages must have non-empty content"
60726072
// "messages: text content blocks must be non-empty"
60736073
if strings.Contains(msg, "non-empty content") || strings.Contains(msg, "empty content") ||
6074-
strings.Contains(msg, "must be non-empty") {
6074+
strings.Contains(msg, "content blocks must be non-empty") {
60756075
logger.LegacyPrintf("service.gateway", "[SignatureCheck] Detected empty content error")
60766076
return true
60776077
}

0 commit comments

Comments
 (0)