Merge pull request #292 from gyptazy/fix/291-catch-stack-trace-when-user-account-is-not-given-or-wrong

fix(proxmox-api): Fix stacktrace output when validating permissions on non existing users in Proxmox
This commit is contained in:
gyptazy
2025-08-25 07:58:32 +02:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
fixed:
- Fix stacktrace output when validating permissions on non existing users in Proxmox (@gyptazy). [#291]

View File

@@ -336,7 +336,15 @@ class ProxmoxApi:
permissions_available = []
# Get the permissions for the current user/token from API
permissions = proxmox_api.access.permissions.get()
try:
permissions = proxmox_api.access.permissions.get()
except proxmoxer.core.ResourceException as api_error:
if "no such user" in str(api_error):
logger.error("Authentication to Proxmox API not possible: User not known - please check your username and config file.")
sys.exit(1)
else:
logger.error(f"Proxmox API error: {api_error}")
sys.exit(1)
# Get all available permissions of the current user/token
for path, permission in permissions.items():