ObjectChanges not created when running Script from EventRule #11807

Closed
opened 2025-12-29 21:50:08 +01:00 by adam · 1 comment
Owner

Originally created by @matejv on GitHub (Nov 4, 2025).

Originally assigned to: @arthanson on GitHub.

NetBox Edition

NetBox Community

NetBox Version

v4.4.5

Python Version

3.12

Steps to Reproduce

  1. Create & upload a custom script with the following content:
from extras.scripts import Script
from tenancy.models import Tenant


class TestSnapshots(Script):
    def run(self, data: dict, commit: bool) -> str:
        tenant = Tenant.objects.get(name="tenant a")
        tenant.snapshot()
        tenant.description = "updated from event rule"
        tenant.full_clean()
        tenant.save()
  1. Create Tenant with name tenant a. Leave description empty.
  2. Create EventRule that will run script. Exact values don't matter, for example:
    • object types: Contact group
    • event types: Create
    • action type: Script
    • script: script uploaded above
  3. Create Tenant group with any values
  4. Check Changelog for Tenant tenant a.

Expected Behavior

An update changelog entry for tenant a is created that indicates change of tenant description.

Observed Behavior

No changelog entry is created.

Originally created by @matejv on GitHub (Nov 4, 2025). Originally assigned to: @arthanson on GitHub. ### NetBox Edition NetBox Community ### NetBox Version v4.4.5 ### Python Version 3.12 ### Steps to Reproduce 1. Create & upload a custom script with the following content: ```py from extras.scripts import Script from tenancy.models import Tenant class TestSnapshots(Script): def run(self, data: dict, commit: bool) -> str: tenant = Tenant.objects.get(name="tenant a") tenant.snapshot() tenant.description = "updated from event rule" tenant.full_clean() tenant.save() ``` 2. Create Tenant with name `tenant a`. Leave description empty. 3. Create EventRule that will run script. Exact values don't matter, for example: - object types: `Contact group` - event types: `Create` - action type: `Script` - script: script uploaded above 4. Create Tenant group with any values 5. Check Changelog for Tenant `tenant a`. ### Expected Behavior An update changelog entry for `tenant a` is created that indicates change of tenant description. ### Observed Behavior No changelog entry is created.
adam added the type: bugstatus: acceptednetboxseverity: low labels 2025-12-29 21:50:08 +01:00
adam closed this issue 2025-12-29 21:50:08 +01:00
Author
Owner

@pheus commented on GitHub (Nov 6, 2025):

When an EventRule runs a Script, NetBox enqueues the job without passing the originating request into the job. Because change logging relies on the current request context, the post‑save signal handler bails out and no ObjectChange is created.

This is related to #14896.

@pheus commented on GitHub (Nov 6, 2025): When an EventRule runs a Script, NetBox enqueues the job without passing the originating `request` into the job. Because change logging relies on the current `request` context, the post‑save signal handler bails out and no `ObjectChange` is created. This is related to #14896.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11807