From 3cf4a1b112b77a30d0a59f9899574444c24673fc Mon Sep 17 00:00:00 2001 From: David Glick Date: Mon, 29 Apr 2024 17:13:06 -0700 Subject: [PATCH] Users service: fix edge case where a userid is returned by search but isn't an actual user (#1775) * fix edge case where a userid is returned by search but isn't an actual user * changelog --- news/1775.bugfix | 1 + src/plone/restapi/services/users/get.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 news/1775.bugfix diff --git a/news/1775.bugfix b/news/1775.bugfix new file mode 100644 index 0000000000..f0b3cd0e47 --- /dev/null +++ b/news/1775.bugfix @@ -0,0 +1 @@ +Users service: Fixed edge case AttributeError if a user is enumerated but doesn't actually exist. @davisagli diff --git a/src/plone/restapi/services/users/get.py b/src/plone/restapi/services/users/get.py index e900b7de6f..235639c785 100644 --- a/src/plone/restapi/services/users/get.py +++ b/src/plone/restapi/services/users/get.py @@ -115,7 +115,9 @@ def _principal_search_results( principals = [] for principal_info in search_for_principal(hunter, self.search_term): principal_id = principal_info[id_key] - principals.append(get_principal_by_id(principal_id)) + principal = get_principal_by_id(principal_id) + if principal is not None: + principals.append(principal) return principals