From 243ff01c55e319c2e3713f5ce7c7e8e0c6bed13b Mon Sep 17 00:00:00 2001
From: Erwan Rouchet <rouchet@teklia.com>
Date: Thu, 6 Jun 2019 12:53:12 +0000
Subject: [PATCH] Ignore empty IIIF manifest metadata

---
 arkindex/dataimport/iiif.py                          | 3 +++
 arkindex/dataimport/tests/manifest_samples/base.json | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/arkindex/dataimport/iiif.py b/arkindex/dataimport/iiif.py
index b7645015da..7732cfdb6b 100644
--- a/arkindex/dataimport/iiif.py
+++ b/arkindex/dataimport/iiif.py
@@ -241,6 +241,9 @@ class ManifestParser(IIIFParser):
             if not all(prop in item for prop in ('label', 'value')):
                 logger.warning('Metadata does not have the required label and value properties')
                 continue
+            if not item['value']:
+                logger.warning('Metadata with label {} has an empty value - ignoring'.format(item['value']))
+                continue
             data.append(item)
 
         def grouper(item):
diff --git a/arkindex/dataimport/tests/manifest_samples/base.json b/arkindex/dataimport/tests/manifest_samples/base.json
index c78944e450..fe89e41c37 100644
--- a/arkindex/dataimport/tests/manifest_samples/base.json
+++ b/arkindex/dataimport/tests/manifest_samples/base.json
@@ -30,6 +30,10 @@
         {
             "label": "Label 1",
             "value": "Value 4"
+        },
+        {
+            "label": "Ignore me",
+            "value": ""
         }
     ],
     "license": "http://creativecommons.org/licenses/by-nc/3.0/deed.fr",
-- 
GitLab