1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #8557/6e0142fe backport][stable-9] bitwarden: Fix KeyError in search_field (#8549) (#8563)

bitwarden: Fix KeyError in search_field (#8549) (#8557)

* bitwarden: Fix KeyError in search_field (#8549)

* Update changelogs/fragments/8557-fix-bug-with-bitwarden.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 6e0142fe3a)

Co-authored-by: Kai <github@sistason.de>
This commit is contained in:
patchback[bot] 2024-06-27 10:19:35 +00:00 committed by GitHub
parent 0dfd02c1ca
commit c88a40d3e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "bitwarden lookup plugin - fix ``KeyError`` in ``search_field`` (https://github.com/ansible-collections/community.general/issues/8549, https://github.com/ansible-collections/community.general/pull/8557)."

View file

@ -174,8 +174,9 @@ class Bitwarden(object):
else: else:
initial_matches = [initial_matches] initial_matches = [initial_matches]
# Filter to only include results from the right field. # Filter to only include results from the right field, if a search is requested by value or field
return [item for item in initial_matches if not search_value or item[search_field] == search_value] return [item for item in initial_matches
if not search_value or not search_field or item.get(search_field) == search_value]
def get_field(self, field, search_value, search_field="name", collection_id=None, organization_id=None): def get_field(self, field, search_value, search_field="name", collection_id=None, organization_id=None):
"""Return a list of the specified field for records whose search_field match search_value """Return a list of the specified field for records whose search_field match search_value