Make domain_lookup return consistent type

It is possible to make Horizon reach the "Pure project admin doesn't
have a domain token" state in domain_lookup by having different policy
files in Keystone and in Horizon, at which point it results in an
unhelpful AttributeError later on, because domain_lookup returns None.

I'm proposing to make it return an empty dict instead, this way Horizon
doesn't crash, but we still get the warning in the logs.

Change-Id: I7a42e8defb2fb348cac8225fb1dcbf5e86c9e65c
This commit is contained in:
Radomir Dopieralski 2019-03-15 09:15:28 +01:00
parent eb98a12bf0
commit 8e13106adb
1 changed files with 1 additions and 1 deletions

View File

@ -247,7 +247,7 @@ def domain_lookup(request):
return dict((d.id, d.name) for d in domains)
except Exception:
LOG.warning("Pure project admin doesn't have a domain token")
return None
return {}
else:
domain = get_default_domain(request)
return {domain.id: domain.name}