zuul-web: config_errors endpoint: return 404 when tenant not found

Fix the endpoint to remove 500 error when tenant is not found.

Change-Id: I1e76d3f120a3d1abec8253f01cd661e0947b3e65
This commit is contained in:
Fabien Boucher
2018-07-12 17:33:29 +02:00
parent 19afda37a3
commit 98d9dbf98f
3 changed files with 8 additions and 0 deletions

View File

@@ -280,6 +280,8 @@ class ZuulWebAPI(object):
config_errors = self.rpc.submitJob(
'zuul:config_errors_list', {'tenant': tenant})
ret = json.loads(config_errors.data[0])
if ret is None:
raise cherrypy.HTTPError(404, 'Tenant %s does not exist.' % tenant)
resp = cherrypy.response
resp.headers['Access-Control-Allow-Origin'] = '*'
return ret