-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed as not planned
Labels
type: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
Deployment Type
Self-hosted
NetBox Version
v4.2.4
Python Version
3.12
Steps to Reproduce
- create a test custom script
$ cat data_source/test.py
from extras.scripts import Script
class test(Script):
def run(self, data, commit):
print(f"data: {data}")
- run the custom script and pass data to it using runscript --data ...
$ ./venv/bin/python3 ./netbox/manage.py runscript -v 3 --data '{"site":1}' test.test
I've reverted the change #18612 to fix it locally
--- netbox/extras/management/commands/runscript.py.org 2025-03-04 13:50:41.594946866 +0000
+++ netbox/extras/management/commands/runscript.py 2025-03-04 14:00:21.957497595 +0000
@@ -91,7 +91,8 @@
instance=script_obj,
user=user,
immediate=True,
- data=form.cleaned_data,
+ #data=form.cleaned_data, this breaks passing data to the script as from.cleaned_data always returns an empty dict, introduced in netbox 4.2.4
+ data=data,
request=NetBoxFakeRequest({
'META': {},
'POST': data,
Expected Behavior
$ ./venv/bin/python3 ./netbox/manage.py runscript -v 3 --data '{"site":1}' test.test
[2025-03-04 14:00:35,804][INFO] - Running script (commit=False)
data: {'site': 1}
[2025-03-04 14:00:35,805][INFO] - Database changes have been reverted automatically.
[2025-03-04 14:00:35,811][INFO] - Script completed in 0 minutes, 0.01 seconds
Observed Behavior
$ ./venv/bin/python3 ./netbox/manage.py runscript -v 3 --data '{"site":1}' test.test
[2025-03-04 13:58:59,889][INFO] - Running script (commit=False)
data: {}
[2025-03-04 13:58:59,890][INFO] - Database changes have been reverted automatically.
[2025-03-04 13:58:59,896][INFO] - Script completed in 0 minutes, 0.01 seconds
Metadata
Metadata
Assignees
Labels
type: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application