Examples of errors detected by the V8005 diagnostic
V8005. The 'then' statement is equivalent to the 'else' statement.
LocalAI
V8005 The 'then' statement is equivalent to the 'else' statement. chat.go 85
func ChatEndpoint(....) echo.HandlerFunc {
....
if len(cleanedContent) > len(lastEmittedCleanedContent) &&
strings.HasPrefix(cleanedContent, lastEmittedCleanedContent) {
deltaContent = cleanedContent[len(lastEmittedCleanedContent):]
lastEmittedCleanedContent = cleanedContent
} else if cleanedContent != lastEmittedCleanedContent {
// If cleaned content changed but not in a simple append,
// extract delta from cleaned content
// This handles cases where thinking tags are removed mid-stream
if lastEmittedCleanedContent == "" {
deltaContent = cleanedContent // <=
lastEmittedCleanedContent = cleanedContent // <=
} else {
// Content changed in non-append way, use the new cleaned content
deltaContent = cleanedContent // <=
lastEmittedCleanedContent = cleanedContent // <=
}
}
....
}
LocalAI
V8005 The 'then' statement is equivalent to the 'else' statement. parse.go 902
func parseXMLWithFormat(s string, format *XMLToolCallFormat) (....) {
....
for _, match := range toolCallMatches {
if len(match) < 3 {
continue
}
....
var functionContent string
if len(match) >= 3 {
if format.ToolSep == "" && format.KeyStart != "" {
functionContent = match[2]
} else {
functionContent = match[2]
}
}
....
}
....
}
sub2api
V8005 The 'then' statement is equivalent to the 'else' statement. schema_cleaner.go 310
func cleanJSONSchemaRecursive(value any) any {
....
if hasKey(schemaMap, "properties") {
schemaMap["type"] = "object"
} else {
// 默认为 string ? or object? Gemini 通常需要明确 type
schemaMap["type"] = "object"
}
....
}
new-api
V8005 The 'then' statement is equivalent to the 'else' statement. relay-claude.go 474
func StreamResponseClaude2OpenAI(....) .... {
....
if claudeResponse.Type == "message_start" {
....
} else if claudeResponse.Type == "content_block_start" {
....
} else if claudeResponse.Type == "content_block_delta" {
....
} else if claudeResponse.Type == "message_delta" {
....
} else if claudeResponse.Type == "message_stop" {
return nil
} else {
return nil
}
....
}
new-api
V8005 The 'then' statement is equivalent to the 'else' statement. ability.go 114
func GetChannel(group string, model string, retry int) (*Channel, error) {
var abilities []Ability
var err error = nil
channelQuery, err := getChannelQuery(group, model, retry)
if err != nil {
return nil, err
}
if common.UsingSQLite || common.UsingPostgreSQL {
err = channelQuery.Order("weight DESC").Find(&abilities).Error
} else {
err = channelQuery.Order("weight DESC").Find(&abilities).Error
}
....
}