fix(cliproxy): tighten session affinity status handling

This commit is contained in:
Tam Nhu Tran
2026-04-28 12:26:42 -04:00
parent 4309db89c3
commit 20f3916d55
2 changed files with 21 additions and 11 deletions
+3 -1
View File
@@ -99,6 +99,8 @@ const MIN_STALE_HIGH_ONLY_GEMINI_MINOR_VERSIONS = 3;
const MIN_STALE_GUESSED_GEMINI_AVERAGE_VARIANTS_PER_MINOR = 2;
const LEGACY_GEMINI_STALE_ALIAS_MIGRATION_VERSION = 16;
const MAX_LEGACY_MANUAL_GEMINI_MINOR_VERSION = 2;
const GO_DURATION_SEGMENT = String.raw`(?:\d+(?:\.\d+)?(?:ns|us|µs|μs|ms|s|m|h))`;
const GO_DURATION_PATTERN = new RegExp(`^${GO_DURATION_SEGMENT}+$`);
/**
* Get provider configuration
@@ -139,7 +141,7 @@ function getSessionAffinityEnabled(): boolean {
function getSessionAffinityTtl(): string {
const ttl = loadOrCreateUnifiedConfig().cliproxy?.routing?.session_affinity_ttl?.trim();
return ttl || '1h';
return ttl && GO_DURATION_PATTERN.test(ttl) ? ttl : '1h';
}
function sanitizeYamlScalar(rawValue: string): string {