Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(cli): stop whoami calling an unreadable credential authenticated

mateo-berrib142d1d76576
diff --git a/litellm/proxy/client/cli/commands/auth.py b/litellm/proxy/client/cli/commands/auth.py
index b3a7db4bed4..ac330ad6892 100644
--- a/litellm/proxy/client/cli/commands/auth.py
+++ b/litellm/proxy/client/cli/commands/auth.py
@@ -867,7 +867,7 @@ def whoami(ctx: click.Context):
click.echo("Not authenticated. Run 'lite login' to authenticate.")
return
- click.echo("Authenticated")
+ click.echo("Authenticated" if token_data.key is not None else "Signed in, but the credential cannot be read")
click.echo(f"User Email: {token_data.user_email or 'Unknown'}")
click.echo(f"User ID: {token_data.user_id or 'Unknown'}")
click.echo(f"User Role: {token_data.user_role or 'Unknown'}")
diff --git a/tests/test_litellm/proxy/client/cli/test_auth_commands.py b/tests/test_litellm/proxy/client/cli/test_auth_commands.py
index 8191a8edca7..1dd8a7ead92 100644
--- a/tests/test_litellm/proxy/client/cli/test_auth_commands.py
+++ b/tests/test_litellm/proxy/client/cli/test_auth_commands.py
@@ -1137,7 +1137,12 @@ class TestKeychainBackedCommands:
assert "could not be read" in result.output
assert "lite login" in result.output
- def test_whoami_flags_a_locked_keychain(self, isolated_home, secret_vault_factory):
+ def test_whoami_does_not_call_a_credential_it_cannot_read_authenticated(
+ self, isolated_home, secret_vault_factory
+ ):
+ """A login whose secret is stuck in an unreachable keychain authenticates nothing. Leading
+ with "Authenticated" and a token age reads as a working session, and sends the user looking
+ for the problem somewhere other than the keychain the notice underneath names."""
_write_home_json(
isolated_home,
"token.json",
@@ -1147,7 +1152,8 @@ class TestKeychainBackedCommands:
result = self.runner.invoke(whoami, obj=obj)
- assert "Authenticated" in result.output
+ assert "Authenticated" not in result.output
+ assert "the credential cannot be read" in result.output
assert "could not be read" in result.output
def test_whoami_names_the_kill_switch_rather_than_a_missing_package(