Scripts executed in dry-run mode trigger webhooks #4251

Closed
opened 2025-12-29 18:34:14 +01:00 by adam · 2 comments
Owner

Originally created by @BarbarossaTM on GitHub (Nov 6, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.7.9
  • NetBox version: 2.9.3

Steps to Reproduce

I wrote a script to deploy new POPs following a codified building plan, which worked great :)

  1. Configure a webhook to trigger on create/update and call some remote URL
  2. Run a script which creates/updates some items within netbox and execute the script in dry-run mode.

No changes to the DB will be written as the DB transaction will be rolled back but webhooks will be triggered.

Expected Behavior

No webhooks will be triggered on dry-run execution of scripts

Observed Behavior

Webhooks are executed for scripts in dry-run mode.

Originally created by @BarbarossaTM on GitHub (Nov 6, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.7.9 * NetBox version: 2.9.3 ### Steps to Reproduce I wrote a [script](https://blog.sdn.clinic/2020/06/deploying-a-pop-with-netbox-scripts/) to deploy new POPs following a codified building plan, which worked great :) 1. Configure a webhook to trigger on create/update and call some remote URL 2. Run a script which creates/updates some items within netbox and execute the script in dry-run mode. No changes to the DB will be written as the DB transaction will be rolled back but webhooks will be triggered. ### Expected Behavior No webhooks will be triggered on dry-run execution of scripts ### Observed Behavior Webhooks are executed for scripts in dry-run mode.
adam added the type: bugstatus: accepted labels 2025-12-29 18:34:14 +01:00
adam closed this issue 2025-12-29 18:34:14 +01:00
Author
Owner

@BarbarossaTM commented on GitHub (Nov 8, 2020):

Update:

I tried to update my script to only call .save() when commit is True which works at most places but seems to fail when querying interfaces/ports of devices created from a Device Type. I'm under the impression that those queries are done against the DB and not the model in RAM.

@BarbarossaTM commented on GitHub (Nov 8, 2020): Update: I tried to update my script to only call `.save()` when `commit` is `True` which works at most places but seems to fail when querying interfaces/ports of devices created from a Device Type. I'm under the impression that those queries are done against the DB and not the model in RAM.
Author
Owner

@jeremystretch commented on GitHub (Nov 9, 2020):

Fixing this probably entails modifying the run_script() function to invoke the change_logging context manager only when commit is true.

@jeremystretch commented on GitHub (Nov 9, 2020): Fixing this probably entails modifying the `run_script()` function to invoke the `change_logging` context manager only when `commit` is true.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4251