image_uploader (attempt #3): fix images upload with no labels

If an image has no label, we set labels to {}; so to build tag_label in
that case we need to catch the TypeError exception or
tag_from_label.format(**labels) will raise, since labels would be NoneType.

We could have remove the default {} for Labels; but it's better to keep
it for further use in the image uploader; when the parameter is required
for certain methods.

Closes-Bug: #1857012
Depends-On: https://review.opendev.org/#/c/706196/
Change-Id: I35d73e7eca6f3cc208eda5d4c78a7bdd6cd7b810
(cherry picked from commit 1b4f32a28a)
This commit is contained in:
Emilien Macchi 2020-01-15 08:55:40 -05:00 committed by wes hayutin
parent 6501655ab1
commit bcec69e0dc
1 changed files with 1 additions and 1 deletions

View File

@ -772,7 +772,7 @@ class BaseImageUploader(object):
tag_label = tag_from_label.format(**labels)
except ValueError as e:
raise ImageUploaderException(e)
except KeyError as e:
except (KeyError, TypeError) as e:
if fallback_tag:
tag_label = fallback_tag
else: