Catch parsing errors in image API
Fixes https://sentry.io/organizations/coreos/issues/664440779/
This commit is contained in:
parent
68300b2644
commit
eef4094f56
1 changed files with 8 additions and 1 deletions
|
@ -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),
|
||||
|
|
Reference in a new issue