Make API errors more informative
Fixes https://jira.coreos.com/browse/QUAY-999
This commit is contained in:
parent
beebe6d5ed
commit
4f152fd7c7
2 changed files with 9 additions and 9 deletions
|
@ -32,7 +32,7 @@ def parse_repository_name(include_tag=False,
|
|||
include_tag=include_tag,
|
||||
allow_library=features.LIBRARY_SUPPORT)
|
||||
except ImplicitLibraryNamespaceNotAllowed:
|
||||
abort(400)
|
||||
abort(400, message='A namespace must be specified explicitly')
|
||||
|
||||
del kwargs[incoming_repo_kwarg]
|
||||
kwargs[ns_kwarg_name] = repo_name_components[0]
|
||||
|
@ -54,7 +54,7 @@ def param_required(param_name, allow_body=False):
|
|||
def decorated(*args, **kwargs):
|
||||
if param_name not in request.args:
|
||||
if not allow_body or param_name not in request.values:
|
||||
abort(make_response('Required param: %s' % param_name, 400))
|
||||
abort(400, message='Required param: %s' % param_name)
|
||||
return wrapped(*args, **kwargs)
|
||||
return decorated
|
||||
return wrapper
|
||||
|
@ -85,7 +85,7 @@ def check_anon_protection(func):
|
|||
if get_authenticated_context() and not get_authenticated_context().is_anonymous:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
abort(401)
|
||||
abort(401, message='Anonymous access is not allowed')
|
||||
|
||||
return wrapper
|
||||
|
||||
|
@ -117,7 +117,8 @@ def require_xhr_from_browser(func):
|
|||
if not has_xhr_header and not app.config.get('DEBUGGING') == True:
|
||||
logger.warning('Disallowed possible RTA to URL %s with user agent %s',
|
||||
request.path, request.user_agent)
|
||||
abort(400)
|
||||
abort(400, message='API calls must be invoked with an X-Requested-With header ' +
|
||||
'if called from a browser')
|
||||
|
||||
return func(*args, **kwargs)
|
||||
return wrapper
|
||||
|
|
Reference in a new issue