From 8fa2bc821149a5594f2373c9f7867a7f0ca129e2 Mon Sep 17 00:00:00 2001 From: Quan Zhou Date: Thu, 29 Aug 2024 17:00:23 +0200 Subject: [PATCH] [enrich] Avoid "-- UNDEFINED --" values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid `-- UNDEFINED --` values for all SortingHat fields when Mordred loses connection to the SortingHat server during the enrichment or autorefresh execution. It will keep the values ​of the `name`, `email`, `id` and `uuid` fields. Signed-off-by: Quan Zhou --- grimoire_elk/enriched/enrich.py | 6 ++++-- releases/unreleased/avoid-'---undefined---'-values.yml | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releases/unreleased/avoid-'---undefined---'-values.yml diff --git a/grimoire_elk/enriched/enrich.py b/grimoire_elk/enriched/enrich.py index f309f5635..29663bfec 100644 --- a/grimoire_elk/enriched/enrich.py +++ b/grimoire_elk/enriched/enrich.py @@ -826,13 +826,16 @@ def get_sh_item_from_identity_cache(self, identity_tuple, backend_name): email=iden['email'], name=iden['name'], username=iden['username']) + iden['uuid'] = identity_id + iden['id'] = identity_id + iden['enrollments'] = [] try: individual = self.get_entity(identity_id) if not individual: msg = "Individual not found given the following identity: {}".format(identity_id) logger.debug(msg) - return sh_item + return iden for indv_identity in individual['identities']: if indv_identity['uuid'] == identity_id: @@ -1054,7 +1057,6 @@ def get_item_sh(self, item, roles=None, date_field=None): sh_fields = self.get_item_sh_fields(identity, item_date, rol=rol) else: sh_fields = self.get_item_no_sh_fields(identity, rol) - eitem_sh.update(sh_fields) if not eitem_sh[rol + '_org_name']: diff --git a/releases/unreleased/avoid-'---undefined---'-values.yml b/releases/unreleased/avoid-'---undefined---'-values.yml new file mode 100644 index 000000000..f21d391c3 --- /dev/null +++ b/releases/unreleased/avoid-'---undefined---'-values.yml @@ -0,0 +1,10 @@ +--- +title: Avoid '-- UNDEFINED --' values +category: fixed +author: Quan Zhou +issue: null +notes: > + Avoid `-- UNDEFINED --` values for all SortingHat fields when + Mordred loses connection to the SortingHat server during the + enrichment or autorefresh execution. It will keep the values + ​of the `name`, `email`, `id` and `uuid` fields.