Skip to content
Open
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
19 changes: 17 additions & 2 deletions src/api/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ pub(super) async fn get_providers(
let instance_dir = (**state.instance_dir.load()).clone();
let secrets_store = state.secrets_store.load();
let openai_oauth_configured = crate::openai_auth::credentials_path(&instance_dir).exists();
let anthropic_oauth_configured = crate::auth::credentials_path(&instance_dir).exists();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
let env_set = |name: &str| {
std::env::var(name)
.ok()
Expand Down Expand Up @@ -450,7 +451,7 @@ pub(super) async fn get_providers(
};

(
has_value("anthropic_key", "ANTHROPIC_API_KEY"),
has_value("anthropic_key", "ANTHROPIC_API_KEY") || anthropic_oauth_configured,
has_value("openai_key", "OPENAI_API_KEY"),
openai_oauth_configured,
has_value("openrouter_key", "OPENROUTER_API_KEY"),
Expand Down Expand Up @@ -482,7 +483,7 @@ pub(super) async fn get_providers(
)
} else {
(
env_set("ANTHROPIC_API_KEY"),
env_set("ANTHROPIC_API_KEY") || anthropic_oauth_configured,
env_set("OPENAI_API_KEY"),
openai_oauth_configured,
env_set("OPENROUTER_API_KEY"),
Expand Down Expand Up @@ -1512,6 +1513,20 @@ pub(super) async fn delete_provider(
}));
}

// Anthropic OAuth credentials are stored as a separate JSON file.
// Remove it so that get_providers no longer reports Anthropic as configured.
if provider == "anthropic" {
let instance_dir = (**state.instance_dir.load()).clone();
let cred_path = crate::auth::credentials_path(&instance_dir);
if cred_path.exists() {
tokio::fs::remove_file(&cred_path).await.map_err(|error| {
tracing::error!(%error, path = %cred_path.display(), "failed to remove Anthropic OAuth credentials");
StatusCode::INTERNAL_SERVER_ERROR
})?;
}
// Fall through to also remove the TOML key if present.
}

// GitHub Copilot has a cached token file alongside the TOML key.
// Remove both the TOML key and the cached token.
if provider == "github-copilot" {
Expand Down