[GH-ISSUE #144] Could we always include resp.text in ResourceException.content? #72

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

Originally created by @tiago8 on GitHub (Sep 2, 2023).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/144

Originally assigned to: @jhollowe on GitHub.

As the title says, would it be possible to always include resp.text in ResourceException.content? Specifically, when hasattr(resp, "reason") is true, the resp.text is not included in the exception which may omit valuable information.

Why?

I was setting up an Ansible playbook to automate the creation of a LXC container but kept running into the error:

Creation of lxc VM 100 failed with exception: 400 Bad Request: Parameter verification failed.

After some debugging I found the issue (invalid rootfs param). It turned out that the API was returning the detailed cause inside resp.text but that wasn't being included in the exception.

As such, always including resp.text in ResourceException.content can provide valuable information for quickly figuring out what is going wrong.

Proposed how

A simple solution would be to replace proxmoxer/core.py#L152 with resp.reason + " Specifically: " + resp.text,

Originally created by @tiago8 on GitHub (Sep 2, 2023). Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/144 Originally assigned to: @jhollowe on GitHub. As the title says, would it be possible to always include `resp.text` in `ResourceException.content`? Specifically, when [hasattr(resp, "reason")](https://github.com/proxmoxer/proxmoxer/blob/d45c72dc5b9983290d23d816065976c4df5b2afe/proxmoxer/core.py#L146-L154) is true, the `resp.text` is not included in the exception which may omit valuable information. ### Why? I was setting up an Ansible playbook to automate the creation of a LXC container but kept running into the error: > Creation of lxc VM 100 failed with exception: 400 Bad Request: Parameter verification failed. After some debugging I found the issue ([invalid rootfs param](https://forum.proxmox.com/threads/storage-local-does-not-support-container-directories-when-creating-new-containter.68317/post-306432)). It turned out that the API was returning the detailed cause inside `resp.text` but that wasn't being included in the exception. As such, always including `resp.text` in `ResourceException.content` can provide valuable information for quickly figuring out what is going wrong. ### Proposed how A simple solution would be to replace [proxmoxer/core.py#L152](https://github.com/proxmoxer/proxmoxer/blob/d45c72dc5b9983290d23d816065976c4df5b2afe/proxmoxer/core.py#L152) with `resp.reason + " Specifically: " + resp.text,`
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#72
No description provided.