diff --git a/swh/vault/cookers/base.py b/swh/vault/cookers/base.py --- a/swh/vault/cookers/base.py +++ b/swh/vault/cookers/base.py @@ -6,6 +6,7 @@ import abc import io import logging +import traceback from typing import ClassVar, Set from psycopg2.extensions import QueryCanceledError @@ -141,10 +142,12 @@ self.backend.set_progress(self.BUNDLE_TYPE, self.swhid, str(e)) except Exception: self.backend.set_status(self.BUNDLE_TYPE, self.swhid, "failed") + tb = traceback.format_exc() self.backend.set_progress( self.BUNDLE_TYPE, self.swhid, - "Internal Server Error. This incident will be reported.", + f"Internal Server Error. This incident will be reported.\n" + f"The full error was:\n\n{tb}", ) logging.exception("Bundle cooking failed.") else: diff --git a/swh/vault/tests/test_cookers_base.py b/swh/vault/tests/test_cookers_base.py --- a/swh/vault/tests/test_cookers_base.py +++ b/swh/vault/tests/test_cookers_base.py @@ -1,8 +1,9 @@ -# Copyright (C) 2018 The Software Heritage developers +# Copyright (C) 2018-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import textwrap from unittest.mock import MagicMock from swh.model.identifiers import CoreSWHID @@ -56,7 +57,16 @@ cooker.backend.put_bundle.assert_not_called() cooker.backend.set_status.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID, "failed") - assert "Nope" not in cooker.backend.set_progress.call_args[0][2] + assert cooker.backend.set_progress.call_args[0][2].startswith( + textwrap.dedent( + """\ + Internal Server Error. This incident will be reported. + The full error was: + + Traceback (most recent call last): + """ + ) + ) cooker.backend.send_notif.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID)