From 92e058d6800e1cb33a0359cdc5c079b55612525c Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Wed, 11 Dec 2013 17:35:13 +0800 Subject: [PATCH] Fix KeyError while generating a WSGI response The KeyError exception raised while generating a WSGI response based on the 413 exception. Because there may be no "Retry-After" attribute in the exception headers. Change-Id: I89eb1878acc2195775be17fbcba8088f2e00bac1 Closes-Bug: #1259867 --- cinder/api/openstack/wsgi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 70d127e81..f07f75a8e 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -1169,8 +1169,9 @@ class Fault(webob.exc.HTTPException): 'message': gettextutils.get_localized_message(explanation, locale)}} if code == 413: - retry = self.wrapped_exc.headers['Retry-After'] - fault_data[fault_name]['retryAfter'] = retry + retry = self.wrapped_exc.headers.get('Retry-After', None) + if retry: + fault_data[fault_name]['retryAfter'] = retry # 'code' is an attribute on the fault tag itself metadata = {'attributes': {fault_name: 'code'}} -- 2.45.2