From dd012fa790bc506895dc8e47496c3e8a537d1400 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Wed, 2 Mar 2022 15:22:28 -0300 Subject: [PATCH] 18574: Fixes bug for keys without values. It turns out that: {}.get('something', {}) != {'something':None}.get('something', {}) ...and when there's no values member on any given vocabulary key, the controller fill it with null, so we have to handle the explicit case of having {value: None} on the exported vocabulary. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- sdk/python/arvados/vocabulary.py | 4 ++-- sdk/python/tests/test_vocabulary.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/python/arvados/vocabulary.py b/sdk/python/arvados/vocabulary.py index ae03ef42db..89698e20af 100644 --- a/sdk/python/arvados/vocabulary.py +++ b/sdk/python/arvados/vocabulary.py @@ -20,11 +20,11 @@ class Vocabulary(object): self.strict_keys = voc_definition.get('strict_tags', False) self.key_aliases = {} - for key_id, val in voc_definition.get('tags', {}).items(): + for key_id, val in (voc_definition.get('tags') or {}).items(): strict = val.get('strict', False) key_labels = [l['label'] for l in val.get('labels', [])] values = {} - for v_id, v_val in val.get('values', {}).items(): + for v_id, v_val in (val.get('values') or {}).items(): labels = [l['label'] for l in v_val.get('labels', [])] values[v_id] = VocabularyValue(v_id, labels) vk = VocabularyKey(key_id, key_labels, values, strict) diff --git a/sdk/python/tests/test_vocabulary.py b/sdk/python/tests/test_vocabulary.py index 56647e8243..cce2ec6233 100644 --- a/sdk/python/tests/test_vocabulary.py +++ b/sdk/python/tests/test_vocabulary.py @@ -65,6 +65,7 @@ class VocabularyTest(unittest.TestCase): {'label': 'Comment'}, {'label': 'Notes'}, ], + 'values': None, }, }, } -- 2.30.2