mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-04 07:27:51 +00:00
fix(cli): keep the proxy's response on a teams 401 so lite shows the proxy's reason
This commit is contained in:
parent
c5ed701362
commit
0b6e096046
2 changed files with 15 additions and 5 deletions
|
|
@ -65,7 +65,9 @@ class TeamsManagementClient:
|
|||
response: Final = requests.get(url, headers=self._get_headers(), params=params, timeout=self._timeout)
|
||||
|
||||
if response.status_code == 401:
|
||||
raise UnauthorizedError("Authentication failed. Check your API key.")
|
||||
raise UnauthorizedError(
|
||||
requests.exceptions.HTTPError("Authentication failed. Check your API key.", response=response)
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
|
@ -122,7 +124,9 @@ class TeamsManagementClient:
|
|||
response: Final = requests.get(url, headers=self._get_headers(), params=params, timeout=self._timeout)
|
||||
|
||||
if response.status_code == 401:
|
||||
raise UnauthorizedError("Authentication failed. Check your API key.")
|
||||
raise UnauthorizedError(
|
||||
requests.exceptions.HTTPError("Authentication failed. Check your API key.", response=response)
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
|
@ -143,7 +147,9 @@ class TeamsManagementClient:
|
|||
response: Final = requests.get(url, headers=self._get_headers(), timeout=self._timeout)
|
||||
|
||||
if response.status_code == 401:
|
||||
raise UnauthorizedError("Authentication failed. Check your API key.")
|
||||
raise UnauthorizedError(
|
||||
requests.exceptions.HTTPError("Authentication failed. Check your API key.", response=response)
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
|
|
|||
|
|
@ -541,8 +541,12 @@ def test_a_rejected_explicit_key_fails_cleanly_without_opening_a_browser(
|
|||
|
||||
@pytest.mark.parametrize(
|
||||
("command", "method", "path"),
|
||||
[(["users", "list"], "GET", "/user/list"), (["keys", "generate"], "POST", "/key/generate")],
|
||||
ids=["users", "keys"],
|
||||
[
|
||||
(["users", "list"], "GET", "/user/list"),
|
||||
(["keys", "generate"], "POST", "/key/generate"),
|
||||
(["teams", "list"], "GET", "/team/list"),
|
||||
],
|
||||
ids=["users", "keys", "teams"],
|
||||
)
|
||||
def test_a_rejected_explicit_key_names_the_reason_the_proxy_gave_without_echoing_the_key(
|
||||
requests_mock: Mocker,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue