<#3443 fix(auth): don't delete cached credentials ...
# flyte-github
a
#3443 fix(auth): don't delete cached credentials when token refresh fails Pull request opened by 1fanwang Why are the changes needed? The authenticators delete the cached credentials whenever a token refresh fails, then fall back to a full re-auth. But
KeyringStore.store()
overwrites in place, so the
delete()
is redundant — and harmful: a transient refresh failure (a network blip, an IdP hiccup) wipes the last-good tokens, including a still-valid
refresh_token
, forcing the user through an unnecessary browser re-login. What changes were proposed in this pull request? Drop the premature
KeyringStore.delete(self._endpoint)
from the refresh-failure paths in the PKCE, device-code, and GCP identity-aware-proxy authenticators. Each fall-through still calls
store()
, so a successful re-auth persists. At the device-flow poll site the surrounding
try/except
existed only to delete-and-re-raise, so it's removed and exceptions propagate unchanged. How was this patch tested? Added
test_pkce_refresh_failure_keeps_cached_credentials
and tightened
test_device_flow_authenticator
, both asserting
delete
isn't called when a refresh fails. Reverting the fix makes both fail with
Expected 'delete' to not have been called. Called 1 times.
Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. flyteorg/flytekit