From 9676d7d8c7f517cd17abaa08d72c9f2e764c0fb5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 21 Jul 2017 13:20:31 -0400 Subject: [PATCH] Make downstream issues show their error in the UI --- endpoints/api/repository.py | 3 ++- endpoints/api/secscan.py | 2 +- endpoints/exception.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/endpoints/api/repository.py b/endpoints/api/repository.py index a782018ea..c76dffd99 100644 --- a/endpoints/api/repository.py +++ b/endpoints/api/repository.py @@ -330,7 +330,8 @@ class RepositoryTrust(RepositoryParamResource): tags, _ = tuf_metadata_api.get_default_tags_with_expiration(namespace, repository) if tags and not tuf_metadata_api.delete_metadata(namespace, repository): - raise DownstreamIssue({'message': 'Unable to delete downstream trust metadata'}) + raise DownstreamIssue('Unable to delete downstream trust metadata') + values = request.get_json() model.set_trust(namespace, repository, values['trust_enabled']) diff --git a/endpoints/api/secscan.py b/endpoints/api/secscan.py index 3929a2e2b..3fd04a66d 100644 --- a/endpoints/api/secscan.py +++ b/endpoints/api/secscan.py @@ -47,7 +47,7 @@ def _security_status_for_image(namespace, repository, repo_image, include_vulner else: data = secscan_api.get_layer_data(repo_image, include_features=True) except APIRequestFailure as arf: - raise DownstreamIssue({'message': arf.message}) + raise DownstreamIssue(arf.message) if data is None: raise NotFound() diff --git a/endpoints/exception.py b/endpoints/exception.py index 537f3f167..abc32cc54 100644 --- a/endpoints/exception.py +++ b/endpoints/exception.py @@ -129,5 +129,5 @@ class NotFound(ApiException): class DownstreamIssue(ApiException): - def __init__(self, payload=None): - ApiException.__init__(self, ApiErrorType.downstream_issue, 520, 'Downstream Issue', payload) + def __init__(self, error_description, payload=None): + ApiException.__init__(self, ApiErrorType.downstream_issue, 520, error_description, payload)