Skip to content

Commit

Permalink
fix(argus.client.base): verify response parameters in check_response
Browse files Browse the repository at this point in the history
This fixes an issue where backend replies with non-standard exception
(can happen when such exception is unhandled on the backend side).
  • Loading branch information
k0machi committed Mar 16, 2023
1 parent 3cc6204 commit 6a9dbbe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion argus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ def check_response(response: requests.Response, expected_code: int = 200):
response_data: JSON = response.json()
LOGGER.debug("API Response: %s", response_data)
if response_data.get("status") != "ok":
exc_args = response_data["response"]["arguments"]
raise ArgusClientError(
f"API Error encountered using endpoint: {response.request.method} {response.request.path_url}",
response_data["response"]["arguments"][0],
exc_args[0] if len(exc_args) > 0 else response_data.get("response", {}).get("exception", "#NoMessage"),
)

def get_url_for_endpoint(self, endpoint: str, location_params: dict[str, str] | None) -> str:
Expand Down

0 comments on commit 6a9dbbe

Please sign in to comment.