Skip to content

Commit 41a92ee

Browse files
committed
Only log the error part of an API response containing an "error" key
If the body consists of a json payload with a top-level key "error" then we want to log only the contents of that key, otherwise log the whole response.
1 parent 38c0caa commit 41a92ee

File tree

1 file changed

+2
-0
lines changed
  • python/neutron-understack/neutron_understack

1 file changed

+2
-0
lines changed

python/neutron-understack/neutron_understack/nautobot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def make_api_request(
6565
response_data = {"status_code": response.status_code, "body": ""}
6666

6767
if response.status_code >= 300:
68+
response_data = response_data.get("error", response_data)
69+
6870
raise NautobotRequestError(
6971
code=response.status_code, url=full_url, body=response_data
7072
)

0 commit comments

Comments
 (0)