Skip to content

Commit 8b604f5

Browse files
authored
Avoid KeyError (#483)
1 parent 050b122 commit 8b604f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

plugins/modules/dcnm_policy.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,9 @@ def dcnm_policy_validate_input(self):
524524
clist, policy_spec
525525
)
526526
if invalid_params:
527-
mesg = 'Invalid parameters in playbook: while processing policy "{0}", Error: {1}'.format(
528-
cfg["name"], invalid_params
529-
)
530-
self.module.fail_json(msg=mesg)
527+
policy_name = cfg.get("name", "unknown")
528+
msg = f"Invalid parameters in playbook: while processing policy {policy_name}, Error: {invalid_params}"
529+
self.module.fail_json(msg=msg)
531530
if self.use_desc_as_key:
532531
# Fail the module when use_desc_as_key is True but description is not given or empty
533532
if cfg.get("description", "") == "":

0 commit comments

Comments
 (0)