From 07b4be4b6155fe6d2149bfcdbafa041642c064b2 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Fri, 12 Oct 2018 10:47:13 +0200
Subject: [PATCH] Fix IndexError when mail is set to an empty list

IndexError raised due to:
{'cn': 'Alessio Curri (new)', 'sAMAccountName': 'alessiocurri2', 'mail': []}

JIRA INFRA-610 #action In Progress
---
 app/utils.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/utils.py b/app/utils.py
index 1d924fb..6dc8d71 100644
--- a/app/utils.py
+++ b/app/utils.py
@@ -111,7 +111,10 @@ def attribute_to_string(value):
     :returns: string
     """
     if isinstance(value, list):
-        return value[0]
+        try:
+            return value[0]
+        except IndexError:
+            return ""
     else:
         return value
 
-- 
GitLab