[PR #81] [MERGED] Fix display of API errors in ProxmoxResource._request #165

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

📋 Pull Request Information

Original PR: https://github.com/proxmoxer/proxmoxer/pull/81
Author: @m-rtijn
Created: 12/23/2021
Status: Merged
Merged: 12/23/2021
Merged by: @jhollowe

Base: developHead: show-api-errors


📝 Commits (1)

📊 Changes

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

View changed files

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

📄 Description

While I was working on the Ansible proxmox module, which uses this API wrapper, I found that when you get a 400 Bad Request: Parameter verification failed error, the Proxmox API actually sends what is wrong with the parameters you send. However, proxmoxer does not add this information in the ResourceException. Here is an example of the JSON with an error that is sent back by the Proxmox API (PVE v7.1-8):

{
  "data": null
  "errors": {
    "password": "value must be at least 5 characters long"
  }
}

I found that this was because of the way JsonSerializer.loads works. It always only sends the data part of the JSON back, which does not include the errors. Because I didn't want to affect other behaviour, I created a new method for sending the errors back. Obviously it is also possible to just change the way JsonSerializer.loads works, but that will probably require changes elsewhere.


🔄 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/81 **Author:** [@m-rtijn](https://github.com/m-rtijn) **Created:** 12/23/2021 **Status:** ✅ Merged **Merged:** 12/23/2021 **Merged by:** [@jhollowe](https://github.com/jhollowe) **Base:** `develop` ← **Head:** `show-api-errors` --- ### 📝 Commits (1) - [`cbfddec`](https://github.com/proxmoxer/proxmoxer/commit/cbfddec13737941fdfb11a0cf110016eed7c4182) Show API errors ### 📊 Changes **2 files changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `proxmoxer/backends/https.py` (+6 -0) 📝 `proxmoxer/core.py` (+1 -1) </details> ### 📄 Description While I was working on the Ansible proxmox module, which uses this API wrapper, I found that when you get a `400 Bad Request: Parameter verification failed` error, the Proxmox API actually sends what is wrong with the parameters you send. However, proxmoxer does not add this information in the `ResourceException`. Here is an example of the JSON with an error that is sent back by the Proxmox API (PVE v7.1-8): ```json { "data": null "errors": { "password": "value must be at least 5 characters long" } } ``` I found that this was because of the way `JsonSerializer.loads` works. It always only sends the `data` part of the JSON back, which does not include the errors. Because I didn't want to affect other behaviour, I created a new method for sending the errors back. Obviously it is also possible to just change the way `JsonSerializer.loads` works, but that will probably require changes elsewhere. --- <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:44 +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#165
No description provided.