fix(proxy_server.py): check if master key is str before hashing

This commit is contained in:
Krrish Dholakia 2024-03-09 16:51:11 -08:00
parent 03f0c968f9
commit 7a29fe9525
2 changed files with 4 additions and 2 deletions

View file

@ -1766,7 +1766,9 @@ class ProxyConfig:
)
if master_key and master_key.startswith("os.environ/"):
master_key = litellm.get_secret(master_key)
litellm_master_key_hash = ph.hash(master_key)
if master_key is not None and isinstance(master_key, str):
litellm_master_key_hash = ph.hash(master_key)
### CUSTOM API KEY AUTH ###
## pass filepath
custom_auth = general_settings.get("custom_auth", None)

View file

@ -55,7 +55,7 @@ def test_custom_auth(client):
}
# Your bearer token
token = os.getenv("PROXY_MASTER_KEY")
print(f"token: {token}")
headers = {"Authorization": f"Bearer {token}"}
response = client.post("/chat/completions", json=test_data, headers=headers)
pytest.fail("LiteLLM Proxy test failed. This request should have been rejected")