Return None when auth refresh fails (#20092)

Right now, if Codex winds up in a state with auth but it can't refresh
the token, the user is left with an unhelpful message that says to log
out and log back in again.

Ultimately, we should prevent that from happening but if it does,
returning None will allow the caller to redirect the user back to the
login page
This commit is contained in:
Gabriel Peal
2026-04-28 16:15:47 -07:00
committed by GitHub
parent 891722849d
commit 5e6cbbadf7
2 changed files with 96 additions and 1 deletions
+7 -1
View File
@@ -148,7 +148,13 @@ impl ModelProvider for ConfiguredModelProvider {
let account = if self.info.requires_openai_auth {
self.auth_manager
.as_ref()
.and_then(|auth_manager| auth_manager.auth_cached())
.and_then(|auth_manager| {
let auth = auth_manager.auth_cached()?;
if auth_manager.refresh_failure_for_auth(&auth).is_some() {
return None;
}
Some(auth)
})
.map(|auth| match &auth {
CodexAuth::ApiKey(_) => Ok(ProviderAccount::ApiKey),
CodexAuth::Chatgpt(_)