What happens
get_api_key_with_store checks the legacy inline key before the credential store
(src/config.rs:~385):
if self.provider.is_anthropic() {
if let Some(key) = &self.anthropic_api_key {
return Ok(key.clone());
}
}
// ... only then the store, then the env var
So on a config that still carries anthropic_api_key = "sk-ant-old", /login anthropic sk-ant-new
writes credentials.toml, reports "Saved credential for anthropic.", triggers a switch — and the
next request still authenticates with the old key.
Why it matters
The symptom is an authentication failure right after a successful-looking login, and the only way to
find the cause is to read config.toml. It is also the rotation path: a user whose key was revoked
does the one thing the UI offers and it silently has no effect.
Suggested fix
Consult the store first and treat the inline key as the last resort before the env var — it is
described in the code as retained only "for configs written before provider existed", which is
exactly the priority a legacy fallback should have. Alternatively, have /login notice the inline key
and either migrate it out of config.toml or say plainly that it is shadowing the new one.
What happens
get_api_key_with_storechecks the legacy inline key before the credential store(
src/config.rs:~385):So on a config that still carries
anthropic_api_key = "sk-ant-old",/login anthropic sk-ant-newwrites
credentials.toml, reports "Saved credential for anthropic.", triggers a switch — and thenext request still authenticates with the old key.
Why it matters
The symptom is an authentication failure right after a successful-looking login, and the only way to
find the cause is to read
config.toml. It is also the rotation path: a user whose key was revokeddoes the one thing the UI offers and it silently has no effect.
Suggested fix
Consult the store first and treat the inline key as the last resort before the env var — it is
described in the code as retained only "for configs written before
providerexisted", which isexactly the priority a legacy fallback should have. Alternatively, have
/loginnotice the inline keyand either migrate it out of
config.tomlor say plainly that it is shadowing the new one.