1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

[PR #10955/e84f59a6 backport][stable-10] fix(pritunl_user): improve resilience to null or missing user parameters (#11013)

fix(pritunl_user): improve resilience to null or missing user parameters (#10955)

* fix(pritunl_user): improve resilience to null or missing user parameters

* added changelog fragment - 10955

* standardize 10955 changelog fragment content



* simplify user params comparison



* simplify list fetch



* simplify remote value retrieval



---------



(cherry picked from commit e84f59a62d)

Co-authored-by: David Jenkins <david.jenkins@twosixtech.com>
Co-authored-by: djenkins <djenkins@twosix.net>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2025-10-29 17:15:21 +00:00 committed by GitHub
parent 103bde7764
commit 0ed510a050
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "pritunl_user - improve resilience when comparing user parameters if remote fields are ``null`` or missing. List parameters (``groups``, ``mac_addresses``) now safely default to empty lists for comparison and avoids ``KeyError`` issues (https://github.com/ansible-collections/community.general/issues/10954, https://github.com/ansible-collections/community.general/pull/10955)."

View file

@ -210,16 +210,18 @@ def add_or_update_pritunl_user(module):
for key in user_params.keys():
# When a param is not specified grab existing ones to prevent from changing it with the PUT request
if user_params[key] is None:
user_params[key] = users[0][key]
user_params[key] = users[0].get(key)
# 'groups' and 'mac_addresses' are list comparison
if key == "groups" or key == "mac_addresses":
if set(users[0][key]) != set(user_params[key]):
remote_list = users[0].get(key) or []
local_list = user_params[key] or []
if set(remote_list) != set(local_list):
user_params_changed = True
# otherwise it is either a boolean or a string
else:
if users[0][key] != user_params[key]:
if users[0].get(key) != user_params[key]:
user_params_changed = True
# Trigger a PUT on the API to update the current user if settings have changed