From b99a8ffb628dd6cb366af16249d80a3140960ae1 Mon Sep 17 00:00:00 2001 From: Simon Caron <8635747+simoncaron@users.noreply.github.com> Date: Fri, 29 Aug 2025 14:07:01 -0400 Subject: [PATCH 1/2] Fix PBS Encryption Key Parsing --- library/proxmox_storage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/proxmox_storage.py b/library/proxmox_storage.py index d213ee1..0bfbb7b 100755 --- a/library/proxmox_storage.py +++ b/library/proxmox_storage.py @@ -299,7 +299,7 @@ import ansible.module_utils.pvesh as pvesh import re import json -from json import JSONDecodeError, loads as parse_json +from json import JSONDecodeError, dumps as parse_json class ProxmoxStorage(object): @@ -355,7 +355,7 @@ def __init__(self, module): "'backup' content type.") try: if self.encryption_key not in ["autogen", None]: - parse_json(self.encryption_key) + self.encryption_key = parse_json(self.encryption_key) except JSONDecodeError: self.module.fail_json(msg=("encryption_key needs to be valid " "JSON or set to 'autogen'.")) @@ -578,7 +578,7 @@ def main(): "zfspool", "btrfs", "pbs", "cifs"]), # Remaining PVE API arguments (depending on type) past this point datastore=dict(default=None, type='str', required=False), - encryption_key=dict(default=None, type='str', required=False, no_log=True), + encryption_key=dict(default=None, type='raw', required=False, no_log=True), fingerprint=dict(default=None, type='str', required=False), master_pubkey=dict(default=None, type='str', required=False), password=dict(default=None, type='str', required=False, no_log=True), From 6b9dd5f01ef1ed264e6e502022ad9d31ea5ea195 Mon Sep 17 00:00:00 2001 From: Simon Caron <8635747+simoncaron@users.noreply.github.com> Date: Fri, 29 Aug 2025 14:29:24 -0400 Subject: [PATCH 2/2] Add parsing validation of json var --- library/proxmox_storage.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/proxmox_storage.py b/library/proxmox_storage.py index 0bfbb7b..01f4a95 100755 --- a/library/proxmox_storage.py +++ b/library/proxmox_storage.py @@ -299,7 +299,7 @@ import ansible.module_utils.pvesh as pvesh import re import json -from json import JSONDecodeError, dumps as parse_json +from json import JSONDecodeError, loads as parse_json, dumps as to_json class ProxmoxStorage(object): @@ -355,7 +355,9 @@ def __init__(self, module): "'backup' content type.") try: if self.encryption_key not in ["autogen", None]: - self.encryption_key = parse_json(self.encryption_key) + if isinstance(self.encryption_key, dict): + self.encryption_key = to_json(self.encryption_key) + parse_json(self.encryption_key) except JSONDecodeError: self.module.fail_json(msg=("encryption_key needs to be valid " "JSON or set to 'autogen'."))