Report raises AbortTransaction() when commit=False and log_failure() has been used #17635
Closed
Description
Deployment Type
Self-hosted
NetBox Version
v4.1.2
Python Version
3.11
Steps to Reproduce
Create a script that logs a failure. Run the script with commit=False
from extras.scripts import Script
class LogFailure(Script):
description = "Log one failure"
def test_error_behavior(self):
self.log_failure("This is a test failure, not a script failure")
Expected Behavior
The script will log one 'Failure' line, rollback database changes, and complete
Observed Behavior
The script logs appropriate, but adds an additional failure, as show below, before rolling back DB changes
An exception occurred: AbortTransaction:
Traceback (most recent call last):
File "/opt/netbox/netbox/extras/jobs.py", line 47, in run_script
raise AbortTransaction()
utilities.exceptions.AbortTransaction