fix: fix rand.init(0) panic in failover.go (#4112)

This commit is contained in:
cyberslack_lee
2026-07-09 14:41:33 +08:00
committed by GitHub
parent e8b9989265
commit 154782660c

View File

@@ -649,6 +649,10 @@ func (c *ProviderConfig) GetGlobalRandomToken() string {
count := len(apiTokens)
switch count {
case 0:
if len(unavailableApiTokens) == 0 {
log.Warn("all tokens are unavailable and no unavailable tokens recorded")
return ""
}
log.Warn("all tokens are unavailable, will use random one of the unavailable tokens")
return unavailableApiTokens[rand.Intn(len(unavailableApiTokens))]
case 1: