Skip to content

Commit

Permalink
fixed wrong json escaping for archiving error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vmakarenko committed Mar 20, 2020
1 parent 02209b4 commit db3de81
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,15 @@ def __str__(self):
def _update_archive_db(task):

a = None
error = task.error
try:
# escape error
if isinstance(task.error, dict):
error = json.dumps(task.error).strip('\"')
# update db
a = task_manager._db_oper.add_or_update_archive(task.repo_id, task.owner, task.version,
task.checksum, task.external_path, task.md, task._repo.name, task._commit.commit_id,
task.status, task.error)
task.status, error)
except Exception as e:
msg = "Cannot update archiving task {}: {}".format(task, e)
_l.critical(msg)
Expand All @@ -236,11 +240,15 @@ def _update_archive_db(task):

def _set_error(task, msg, error):
task.msg = msg
task.error = json.dumps({
if error is not None and error:
error = json.dumps(error).strip('\"')
else:
error = ''
task.error = {
'status': task.status,
'ts': str(datetime.now()),
'error': error,
})
'error': error,
}
_l.error(json.dumps({'message': msg, 'error': task.error}))

def _set_critical_error(task, msg, error):
Expand Down

0 comments on commit db3de81

Please sign in to comment.