mirror of
https://github.com/proxmoxer/proxmoxer.git
synced 2026-04-25 07:06:00 +03:00
[GH-ISSUE #172] proxmoxer doesn't distinguish between error types #92
Labels
No labels
backend:https
backend:local
backend:openssh
backend:ssh_paramiko
pull-request
status:ansible-issue
status:help-wanted
status:info-needed
status:proxmox-issue
status:review-needed
type:bug 🐞
type:dependency ⛓️
type:docs 📝
type:enhancement ⏫
type:maintenance 🛠️
type:meta
type:question ❓
type:request ✋
type:testing 🧪
version:1.x
version:latest
version:py2
version:py3
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/proxmoxer#92
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kaysond on GitHub (Aug 27, 2024).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/172
Originally assigned to: @kaysond on GitHub.
Hi. I'd like to use proxmoxer for an ansible collection I'm writing that implements all of the PVE API paths. Ansible modules (generally) get run on the target host, which means using the local backend and the pvesh.
The problem I'm running into is that when pvesh returns non-zero, proxmoxer throws a
proxmoxer.core.ResourceExceptionwith a500 Internal Server Errorregardless of the pvesh error code. pvesh itself, though, distinguishes between different error types. For example, it returns 1 if there is no handler defined for a given API path (e.g. if the path doesn't exist), but it returns 2 if the handler exists, but the parameter doesn't. See below for an example.This is an important distinction for something like ansible because the parameter not existing isn't necessarily an error. It could be that we want to check if it exists before creating/updating. But if the API path is wrong, or some other issue occurs, we'd want the module to also throw an error.
I don't really want to parse the exception text in my module, so I'm hoping you'd be open to addressing this in the library. Happy to contribute the fix.
@jhollowe commented on GitHub (Aug 29, 2024):
If pulling a field off the ResourceException object would work for you, this should be doable. I think it would be cleaner to change the existing field(s) on the exception object to contain the exit code of the
*shprogram, but that would break anything expecting the existing error messages.I would add a new field to the ResourceException for the exit code, something like
exit_codewhich is always0for HTTPS and is the exit code of the command for SSH/local.@kaysond commented on GitHub (Aug 29, 2024):
Yeah I think a new field on the exception would be totally fine. I just discovered a separate problem, though, and that is that the error code doesn't seem to be consistent. I asked about it here: https://forum.proxmox.com/threads/pvesh-exit-codes-are-not-consistent.153582/