From 8fa18fd9960fc1f42527e6b51b3053ea951fa748 Mon Sep 17 00:00:00 2001 From: Michal Konečný Date: Jan 11 2023 13:57:43 +0000 Subject: Enhance error message posted by scm_request_processor This is enhancement of error message for creating new branch in scm_request_processor. This should help analyze the issue that is currently happening on https://pagure.io/releng/fedora-scm-requests/issue/50370 Signed-off-by: Michal Konečný --- diff --git a/toddlers/plugins/scm_request_processor.py b/toddlers/plugins/scm_request_processor.py index 04aae57..8663eea 100644 --- a/toddlers/plugins/scm_request_processor.py +++ b/toddlers/plugins/scm_request_processor.py @@ -198,13 +198,17 @@ class SCMRequestProcessor(ToddlerBase): try: self.process_ticket(issue) - except BaseException: + except BaseException as e: self.pagure_io.add_comment_to_issue( issue["id"], namespace=PROJECT_NAMESPACE, - comment="Error happened during processing:\n{0}".format( - traceback.format_exc() - ), + comment=( + "Error happened during processing:\n" + "{0}\n\n" + "```\n" + "{1}\n" + "```\n" + ).format(str(e), traceback.format_exc()), ) def process_ticket(self, issue: dict): diff --git a/toddlers/utils/pagure.py b/toddlers/utils/pagure.py index 9b2aa50..ba30cac 100644 --- a/toddlers/utils/pagure.py +++ b/toddlers/utils/pagure.py @@ -375,11 +375,32 @@ class Pagure: namespace, repo, response.status_code ) ) - if response.headers.get('content-type') == 'application/json': + + response_json = None + if response.headers.get("content-type") == "application/json": + response_json = response.json() log.error("Received response: {0}".format(response.json())) raise PagureError( - "Couldn't create branch in project '{0}/{1}'".format(namespace, repo) + ( + "Couldn't create branch in project '{0}/{1}'\n" + "Request to `{2}`:\n" + "```\n" + "{3}\n" + "```\n" + "Response:\n" + "```\n" + "{4}\n" + "```\n" + "Status code: {5}" + ).format( + namespace, + repo, + branch_api_url, + payload, + response_json, + response.status_code, + ) ) def set_monitoring_status(