Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(auth): catch forbidden cache access error #8853

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/turborepo-auth/src/auth/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
pub use error::Error;
use reqwest::Url;
use tokio::sync::OnceCell;
use tracing::warn;
use tracing::{debug, warn};
use turborepo_api_client::{CacheClient, Client, TokenClient};
use turborepo_ui::{start_spinner, BOLD, UI};

Expand Down Expand Up @@ -49,6 +49,7 @@ pub async fn login<T: Client + TokenClient + CacheClient>(
// Check if passed in token exists first.
if !force {
if let Some(token) = existing_token {
debug!("found existing turbo token");
let token = Token::existing(token.into());
if token
.is_valid(
Expand All @@ -64,6 +65,7 @@ pub async fn login<T: Client + TokenClient + CacheClient>(
// The extraction can return an error, but we don't want to fail the login if
// the token is not found.
if let Ok(Some(token)) = extract_vercel_token() {
debug!("found existing Vercel token");
let token = Token::existing(token);
if token
.is_valid(
Expand Down
6 changes: 6 additions & 0 deletions crates/turborepo-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ impl Token {
turborepo_api_client::Error::UnknownStatus { code, .. } if code == "forbidden" => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this was ever valid, but keeping in case there's a way this can get hit that I'm not seeing. Timeboxing this fix so not trying to fully trace responses we can get from this endpoint.

Ok(false)
}
// If the entire request fails with 403 also return false
turborepo_api_client::Error::ReqwestError(e)
if e.status() == Some(reqwest::StatusCode::FORBIDDEN) =>
{
Ok(false)
}
_ => Err(e.into()),
},
}
Expand Down
Loading