diff --git a/netbox/core/jobs.py b/netbox/core/jobs.py index 32b546b207..264313e620 100644 --- a/netbox/core/jobs.py +++ b/netbox/core/jobs.py @@ -25,7 +25,7 @@ def sync_datasource(job, *args, **kwargs): job.terminate() except Exception as e: - job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e)) + job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e)) DataSource.objects.filter(pk=datasource.pk).update(status=DataSourceStatusChoices.FAILED) if type(e) in (SyncError, JobTimeoutException): logging.error(e) diff --git a/netbox/extras/management/commands/runscript.py b/netbox/extras/management/commands/runscript.py index 97ee39f501..a5da7b3b24 100644 --- a/netbox/extras/management/commands/runscript.py +++ b/netbox/extras/management/commands/runscript.py @@ -59,7 +59,7 @@ def _run_script(): logger.error(f"Exception raised during script execution: {e}") clear_events.send(request) job.data = ScriptOutputSerializer(script).data - job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e)) + job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e)) logger.info(f"Script completed in {job.duration}") diff --git a/netbox/extras/reports.py b/netbox/extras/reports.py index c8a13fe15d..90641cc84a 100644 --- a/netbox/extras/reports.py +++ b/netbox/extras/reports.py @@ -41,7 +41,7 @@ def run_report(job, *args, **kwargs): try: report.run(job) except Exception as e: - job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e)) + job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e)) logging.error(f"Error during execution of report {job.name}") finally: # Schedule the next job if an interval has been set @@ -230,7 +230,7 @@ def run(self, job): stacktrace = traceback.format_exc() self.log_failure(None, f"An exception occurred: {type(e).__name__}: {e}
{stacktrace}
") logger.error(f"Exception raised during report execution: {e}") - job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e)) + job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e)) # Perform any post-run tasks self.post_run() diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py index 495957fd97..f28465547b 100644 --- a/netbox/extras/scripts.py +++ b/netbox/extras/scripts.py @@ -527,7 +527,7 @@ def _run_script(): logger.error(f"Exception raised during script execution: {e}") script.log_info("Database changes have been reverted due to error.") job.data = ScriptOutputSerializer(script).data - job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=str(e)) + job.terminate(status=JobStatusChoices.STATUS_ERRORED, error=repr(e)) if request: clear_events.send(request)