Skip to content

Commit 6b9dd5f

Browse files
committed
Add parsing validation of json var
1 parent b99a8ff commit 6b9dd5f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/proxmox_storage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
import ansible.module_utils.pvesh as pvesh
300300
import re
301301
import json
302-
from json import JSONDecodeError, dumps as parse_json
302+
from json import JSONDecodeError, loads as parse_json, dumps as to_json
303303

304304

305305
class ProxmoxStorage(object):
@@ -355,7 +355,9 @@ def __init__(self, module):
355355
"'backup' content type.")
356356
try:
357357
if self.encryption_key not in ["autogen", None]:
358-
self.encryption_key = parse_json(self.encryption_key)
358+
if isinstance(self.encryption_key, dict):
359+
self.encryption_key = to_json(self.encryption_key)
360+
parse_json(self.encryption_key)
359361
except JSONDecodeError:
360362
self.module.fail_json(msg=("encryption_key needs to be valid "
361363
"JSON or set to 'autogen'."))

0 commit comments

Comments
 (0)