Skip to content

Bug: a legacy inline anthropic_api_key silently shadows /login anthropic #20

Description

@Dione-b

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions