From 8124eed3cbfd93e2a9a706da0c02bc5c31e03833 Mon Sep 17 00:00:00 2001 From: Jiri Kyjovsky Date: Tue, 8 Aug 2023 18:19:32 +0200 Subject: [PATCH] frontend: return empty dict instead of null in API calls to BE get_build_record and get_srpm_build_record methods returns None in case of exception or empty task which results in null response in API endpoints. Backend worker don't expect null value, tries to unpack it and fails --- .../coprs/views/backend_ns/backend_general.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py index 59a11c877..9829e3ba9 100755 --- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py +++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py @@ -354,6 +354,9 @@ def get_build_task(task_id): try: task = BuildsLogic.get_build_task(task_id) build_record = get_build_record(task) + if build_record is None: + build_record = {} + return flask.jsonify(build_record) except CoprHttpException as ex: jsonout = flask.jsonify({"msg": str(ex)}) @@ -370,6 +373,9 @@ def get_srpm_build_task(build_id): jsonout.status_code = 404 return jsonout build_record = get_srpm_build_record(task) + if build_record is None: + build_record = {} + return flask.jsonify(build_record)