on main help sign in
fix(hyper): fix re-authorization flow not triggering on certain conditions (#2703)

We attempt to refresh tokens in two scenarios: * Pro-actively, when we expiration date passed before a request * Reactively, when we try a request but a 401 was returned The error / event handling that shows a dialog asking the user to re-authenticate is dependent on code that runs for the second scenario. This means that the dialog might not show on the first scenario, if refreshing the token fails. If refreshing a token fails, continue with the previous token. Let it fail and the 401 will trigger a re-authorization dialog. I caught this because I was switching between local vs. prod Hyper a lot.

commite5d95aa79c55b11476d6eb1a5818955844605bdb authorAndrey Nering <andreynering@users.noreply.github.com> dateFri 24 Apr 2026, 11:27 (6 months ago) parente5b5a40
1 file changed+3−1
internal/agent/coordinator.go+3−1
internal/agent/coordinator.go+3−1
@@ -186,7 +186,9 @@ func (c *coordinator) Run(ctx context.Context, sessionID string, prompt string,
186186 if providerCfg.OAuthToken != nil && providerCfg.OAuthToken.IsExpired() {
187187 slog.Debug("Token needs to be refreshed", "provider", providerCfg.ID)
188188 if err := c.refreshOAuth2Token(ctx, providerCfg); err != nil {
189− return nil, err
189+ // NOTE(@andreynering): We don't return here because the event handling to ask the user to reauthenticate
190+ // depends on the flow below. If refresh fails, proceed with the token we have.
191+ slog.Error("Failed to refresh OAuth2 token. Proceeding with existing token.", "error", err)
190192 }
191193 }
192194