Merge pull request #3372 from quay/small-exception-fixes
Small exception fixes
This commit is contained in:
commit
66ddf66fb0
3 changed files with 18 additions and 2 deletions
7
app.py
7
app.py
|
@ -11,6 +11,7 @@ from flask_login import LoginManager
|
|||
from flask_mail import Mail
|
||||
from flask_principal import Principal
|
||||
from jwkest.jwk import RSAKey
|
||||
from werkzeug.exceptions import HTTPException
|
||||
|
||||
import features
|
||||
|
||||
|
@ -143,7 +144,11 @@ FILTERED_VALUES = [
|
|||
|
||||
@app.after_request
|
||||
def _request_end(resp):
|
||||
jsonbody = request.get_json(force=True, silent=True)
|
||||
try:
|
||||
jsonbody = request.get_json(force=True, silent=True)
|
||||
except HTTPException:
|
||||
jsonbody = None
|
||||
|
||||
values = request.values.to_dict()
|
||||
|
||||
if jsonbody and not isinstance(jsonbody, dict):
|
||||
|
|
|
@ -8,11 +8,18 @@ from endpoints.exception import NotFound
|
|||
|
||||
|
||||
def image_dict(image, with_history=False, with_tags=False):
|
||||
parsed_command = None
|
||||
if image.command:
|
||||
try:
|
||||
parsed_command = json.loads(image.command)
|
||||
except (ValueError, TypeError):
|
||||
parsed_command = {'error': 'Could not parse command'}
|
||||
|
||||
image_data = {
|
||||
'id': image.docker_image_id,
|
||||
'created': format_date(image.created),
|
||||
'comment': image.comment,
|
||||
'command': json.loads(image.command) if image.command else None,
|
||||
'command': parsed_command,
|
||||
'size': image.image_size,
|
||||
'uploading': image.uploading,
|
||||
'sort_index': len(image.parents),
|
||||
|
|
|
@ -843,6 +843,10 @@ def redirect_to_repository(namespace_name, repo_name, tag_name):
|
|||
@process_oauth
|
||||
@anon_protect
|
||||
def redirect_to_namespace(namespace):
|
||||
okay, _ = model.user.validate_username(namespace)
|
||||
if not okay:
|
||||
abort(404)
|
||||
|
||||
user_or_org = model.user.get_user_or_org(namespace)
|
||||
if not user_or_org:
|
||||
abort(404)
|
||||
|
|
Reference in a new issue