From d62a0d7d8d94aa01751558fd5e94386c74a0e54c Mon Sep 17 00:00:00 2001 From: Martin Hauser Date: Fri, 6 Mar 2026 15:15:54 +0100 Subject: [PATCH] fix(extras): Add missing COOKIES and method to NetBoxFakeRequest Populate COOKIES dict and set method to POST in runscript command's NetBoxFakeRequest. Ensures the fake request object more closely mimics a real Django request, preventing potential issues with code expecting these attributes. Fixes #21486 --- netbox/extras/management/commands/runscript.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/netbox/extras/management/commands/runscript.py b/netbox/extras/management/commands/runscript.py index 8b002dbd7..71f398c18 100644 --- a/netbox/extras/management/commands/runscript.py +++ b/netbox/extras/management/commands/runscript.py @@ -81,7 +81,7 @@ class Command(BaseCommand): logger.error(f'\t{field}: {error.get("message")}') raise CommandError() - # Remove extra fields from ScriptForm before passng data to script + # Remove extra fields from ScriptForm before passing data to script form.cleaned_data.pop('_schedule_at') form.cleaned_data.pop('_interval') form.cleaned_data.pop('_commit') @@ -94,10 +94,12 @@ class Command(BaseCommand): data=form.cleaned_data, request=NetBoxFakeRequest({ 'META': {}, + 'COOKIES': {}, 'POST': data, 'GET': {}, 'FILES': {}, 'user': user, + 'method': 'POST', 'path': '', 'id': uuid.uuid4() }),