[PR #99] [MERGED] fix error handling for APIs that don't give a dict in the response #174

Closed
opened 2026-02-27 15:46:46 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/proxmoxer/proxmoxer/pull/99
Author: @wuillaumea
Created: 5/13/2022
Status: Merged
Merged: 5/14/2022
Merged by: @jhollowe

Base: developHead: fix-error-response


📝 Commits (2)

  • e2f58f0 add KeyError when response doesn't put errors as a key
  • 042b29b Only display errors when present

📊 Changes

2 files changed (+2 additions, -2 deletions)

View changed files

📝 proxmoxer/backends/https.py (+1 -1)
📝 proxmoxer/core.py (+1 -1)

📄 Description

addresses https://github.com/proxmoxer/proxmoxer/issues/96

before

...
    print(client.nodes(node_id).storage("local").status.get())
  File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 143, in get
    return self(args)._request("GET", params=params)
  File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 129, in _request
    errors=(self._store["serializer"].loads_errors(resp) or {}),
  File "/usr/local/lib/python3.8/dist-packages/proxmoxer/backends/https.py", line 181, in loads_errors
    return json.loads(response.text)["errors"]
KeyError: 'errors'

now

...
    print(client.nodes(node_id).storage("local").status.get())
  File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 143, in get
    return self(args)._request("GET", params=params)
  File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 123, in _request
    raise ResourceException(
proxmoxer.core.ResourceException: 403 Forbidden: Permission check failed (/storage/local, Datastore.Audit|Datastore.AllocateSpace) - {'errors': b'{"data":null}'}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/proxmoxer/proxmoxer/pull/99 **Author:** [@wuillaumea](https://github.com/wuillaumea) **Created:** 5/13/2022 **Status:** ✅ Merged **Merged:** 5/14/2022 **Merged by:** [@jhollowe](https://github.com/jhollowe) **Base:** `develop` ← **Head:** `fix-error-response` --- ### 📝 Commits (2) - [`e2f58f0`](https://github.com/proxmoxer/proxmoxer/commit/e2f58f0edec6e4f220c4473faa70ef5afdb8e678) add KeyError when response doesn't put errors as a key - [`042b29b`](https://github.com/proxmoxer/proxmoxer/commit/042b29bec051c49f718401fe901f161218693c5b) Only display errors when present ### 📊 Changes **2 files changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `proxmoxer/backends/https.py` (+1 -1) 📝 `proxmoxer/core.py` (+1 -1) </details> ### 📄 Description addresses https://github.com/proxmoxer/proxmoxer/issues/96 before ``` ... print(client.nodes(node_id).storage("local").status.get()) File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 143, in get return self(args)._request("GET", params=params) File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 129, in _request errors=(self._store["serializer"].loads_errors(resp) or {}), File "/usr/local/lib/python3.8/dist-packages/proxmoxer/backends/https.py", line 181, in loads_errors return json.loads(response.text)["errors"] KeyError: 'errors' ``` now ``` ... print(client.nodes(node_id).storage("local").status.get()) File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 143, in get return self(args)._request("GET", params=params) File "/usr/local/lib/python3.8/dist-packages/proxmoxer/core.py", line 123, in _request raise ResourceException( proxmoxer.core.ResourceException: 403 Forbidden: Permission check failed (/storage/local, Datastore.Audit|Datastore.AllocateSpace) - {'errors': b'{"data":null}'} ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 15:46:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmoxer#174
No description provided.