rm misleading token refresh log (#787)

Very chatty log for when there is a valid token, but says token refresh
occurred which may not actually be true.

downleveled and corrected this log and added an actual info on token
refresh success (error gets logged by the caller)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: only adjusts logging around CAS auth token refresh without
changing token refresh logic or request behavior.
> 
> **Overview**
> Removes the unconditional "token refresh successful" info log from
`AuthMiddleware::get_token` so normal requests that reuse a still-valid
token no longer claim a refresh happened.
> 
> Adds an `info!` log in `TokenProvider::get_valid_token` that emits
only after a successful refresh (including the new expiry), while
keeping failure logging in the middleware.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2a9215c163. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
Assaf Vayner
2026-04-09 15:27:46 -07:00
committed by GitHub
parent 9bdaf1e305
commit 693945c84c
2 changed files with 6 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use derivative::Derivative;
use reqwest_middleware::ClientWithMiddleware;
use thiserror::Error;
use tracing::info;
use crate::common::auth::CredentialHelper;
@@ -193,6 +194,7 @@ impl TokenProvider {
let (new_token, new_expiry) = self.refresher.refresh().await?;
self.token = new_token;
self.expiration = new_expiry;
info!(new_expiry = new_expiry, "Token refreshed");
}
Ok(self.token.clone())
}

View File

@@ -303,16 +303,10 @@ impl AuthMiddleware {
/// don't have a valid token and thus any calls would fail.
async fn get_token(&self) -> Result<String> {
let mut provider = self.token_provider.lock().await;
provider
.get_valid_token()
.await
.map_err(|err| {
warn!(?err, "Token refresh failed");
ClientError::AuthError(err)
})
.inspect(|_token| {
info!("Token refresh successful for CAS authentication");
})
provider.get_valid_token().await.map_err(|err| {
warn!(?err, "Token refresh failed");
ClientError::AuthError(err)
})
}
}