Report raises AbortTransaction() when commit=False and log_failure() has been used #10300

Closed
opened 2025-12-29 21:29:36 +01:00 by adam · 0 comments
Owner

Originally created by @craized on GitHub (Sep 27, 2024).

Originally assigned to: @arthanson on GitHub.

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
Originally created by @craized on GitHub (Sep 27, 2024). Originally assigned to: @arthanson on GitHub. ### 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 ```
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:29:36 +01:00
adam closed this issue 2025-12-29 21:29:36 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10300