Skip to content

fix(auth): retain session affinity on transient errors - #212

Open
warelik wants to merge 1 commit into
kaitranntt:mainfrom
warelik:ao/airouters-15-session-affinity-retention
Open

fix(auth): retain session affinity on transient errors#212
warelik wants to merge 1 commit into
kaitranntt:mainfrom
warelik:ao/airouters-15-session-affinity-retention

Conversation

@warelik

@warelik warelik commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Ports router-for-me/CLIProxyAPI#5109 into Plus.

Summary

  • Transient errors (5xx, 429, 408, cloudflare challenge) now retain the primary session binding.
  • Terminal auth errors (401/402/403/404, invalid_grant, unsupported model) still release it.
  • Added a dedicated fallbackCache so a single sticky fallback is used while the primary cools down, then the session returns to the primary once it recovers.
  • Added SessionCache.Aliases(sessionID).
  • Added the full upstream session_affinity_retention_test.go suite.
  • Removed the now-unused session quarantine mechanism.

Behavior flip

This intentionally reverses the release-on-failure semantics pinned since #188, as discussed in #204. Existing tests that asserted the old purge-and-rebind behavior have been updated to the retention expectations:

  • TestSessionAffinity_RetryableFailureInvalidatesMatchingBinding
  • TestSessionAffinity_StreamFailureThroughWrapperInvalidates
  • TestSessionAffinitySelector_FailoverWhenAuthUnavailable
  • TestManagerSessionAffinityPreservesBindingAcrossHigherPriorityRecovery

Closes #204

Port upstream #5109: primary session binding is now retained across
5xx/429/408 and cloudflare challenges, while terminal auth rejections
(401/402/403/404, invalid_grant, unsupported model) still release it.
A sticky temporary fallback cache keeps failover from flapping while the
primary credential cools down, then returns to the warm cache on recovery.

This flips the Plus-pinned release-on-failure behavior and removes the
session quarantine mechanism that is no longer needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session affinity retention on transient errors: port blocked by pinned release-on-failure semantics

1 participant