fix(gateway): harden digest logging and align antigravity ops

- avoid panic by using safe UUID prefix truncation in Gemini digest fallback logs\n- remove unconditional Antigravity 429 full-body debug logs and honor log truncation config\n- align Antigravity quick preset mappings to opus 4.6-thinking targets only\n- restore scope rate-limit aggregation/output in ops availability stats
This commit is contained in:
shaw
2026-02-07 17:12:15 +08:00
parent c4615a1224
commit 1439eb39a9
5 changed files with 57 additions and 10 deletions

View File

@@ -294,7 +294,7 @@ func (h *GatewayHandler) GeminiV1BetaModels(c *gin.Context) {
sessionBoundAccountID = foundAccountID
geminiSessionUUID = foundUUID
log.Printf("[Gemini] Digest fallback matched: uuid=%s, accountID=%d, chain=%s",
foundUUID[:8], foundAccountID, truncateDigestChain(geminiDigestChain))
safeShortPrefix(foundUUID, 8), foundAccountID, truncateDigestChain(geminiDigestChain))
// 关键:如果原 sessionKey 为空,使用 prefixHash + uuid 作为 sessionKey
// 这样 SelectAccountWithLoadAwareness 的粘性会话逻辑会优先使用匹配到的账号
@@ -650,6 +650,15 @@ func truncateDigestChain(chain string) string {
return chain[:50] + "..."
}
// safeShortPrefix 返回字符串前 n 个字符;长度不足时返回原字符串。
// 用于日志展示,避免切片越界。
func safeShortPrefix(value string, n int) string {
if n <= 0 || len(value) <= n {
return value
}
return value[:n]
}
// derefGroupID 安全解引用 *int64nil 返回 0
func derefGroupID(groupID *int64) int64 {
if groupID == nil {