Skip to content
Open
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
11 changes: 7 additions & 4 deletions src-tauri/src/modules/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,13 @@ pub async fn fetch_quota_with_cache(

// ✅ Special handling for 403 Forbidden - return directly, no retry
if status == rquest::StatusCode::FORBIDDEN {
let body = response.text().await.unwrap_or_default();
crate::modules::logger::log_warn(&format!(
"Account unauthorized (403 Forbidden), marking as forbidden"
"Account unauthorized (403 Forbidden): {}", body
));
let mut q = QuotaData::new();
q.is_forbidden = true;
q.forbidden_reason = Some(if body.is_empty() { "403 Forbidden".to_string() } else { body });
q.subscription_tier = subscription_tier.clone();
return Ok((q, project_id.clone()));
}
Expand Down Expand Up @@ -453,7 +455,8 @@ pub async fn warm_up_all_accounts() -> Result<String, String> {
"[Warmup] Account {} returned 403 Forbidden during quota fetch, marking as forbidden",
email
));
let _ = crate::modules::account::mark_account_forbidden(&id, "Warmup: 403 Forbidden - quota fetch denied");
let reason = fresh_quota.forbidden_reason.as_deref().unwrap_or("403 Forbidden - quota fetch denied");
let _ = crate::modules::account::mark_account_forbidden(&id, reason);
continue;
}
let mut account_warmed_series = std::collections::HashSet::new();
Expand Down Expand Up @@ -582,9 +585,9 @@ pub async fn warm_up_account(account_id: &str) -> Result<String, String> {
"[Warmup] Account {} returned 403 Forbidden during quota fetch, marking as forbidden",
email
));
let reason = "Warmup: 403 Forbidden - quota fetch denied";
let reason = fresh_quota.forbidden_reason.as_deref().unwrap_or("403 Forbidden - quota fetch denied");
let _ = crate::modules::account::mark_account_forbidden(account_id, reason);
return Err("Account is forbidden (403)".to_string());
return Err(format!("Account is forbidden: {}", reason));
}

let mut models_to_warm = Vec::new();
Expand Down
6 changes: 4 additions & 2 deletions src-tauri/src/modules/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ pub fn start_scheduler(app_handle: Option<tauri::AppHandle>, proxy_state: crate:
"[Scheduler] Account {} returned 403 Forbidden during quota fetch, marking as forbidden",
account.email
));
let _ = account::mark_account_forbidden(&account.id, "Scheduler: 403 Forbidden - quota fetch denied");
let reason = fresh_quota.forbidden_reason.as_deref().unwrap_or("403 Forbidden - quota fetch denied");
let _ = account::mark_account_forbidden(&account.id, reason);
continue;
}

Expand Down Expand Up @@ -289,7 +290,8 @@ pub async fn trigger_warmup_for_account(account: &Account) {
"[Scheduler] Account {} returned 403 Forbidden during quota fetch, marking as forbidden",
account.email
));
let _ = account::mark_account_forbidden(&account.id, "Scheduler: 403 Forbidden - quota fetch denied");
let reason = fresh_quota.forbidden_reason.as_deref().unwrap_or("403 Forbidden - quota fetch denied");
let _ = account::mark_account_forbidden(&account.id, reason);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/proxy/handlers/claude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ pub async fn handle_messages(
if let Err(e) = token_manager.set_forbidden(&account_id, &error_text).await {
tracing::error!("Failed to set forbidden status for {}: {}", email, e);
} else {
tracing::warn!("[Claude] Account {} marked as forbidden due to 403", email);
tracing::warn!("[Claude] Account {} marked as forbidden due to 403: {}", email, &error_text[..error_text.len().min(500)]);
}
}

Expand Down