Custom script execution stuck at "Results pending..." while Django reports template errors #5991

Closed
opened 2025-12-29 19:35:24 +01:00 by adam · 2 comments
Owner

Originally created by @pn-pn on GitHub (Jan 24, 2022).

NetBox version

v3.1.6

Python version

3.9

Steps to Reproduce

  1. Launch Netbox in Kubernetes using Helm: https://github.com/bootc/netbox-chart/blob/master/values.yaml and the official Docker image "netboxcommunity/netbox:v3.1-ldap" (although I'd try to reproduce this issue in any Kubernetes or Docker environment first)
    1.1. Create a configmap with the custom script presented in the docs (https://netbox.readthedocs.io/en/stable/customization/custom-scripts/):
apiVersion: v1
data:
  docsscript.py: |+
    from django.utils.text import slugify

    from dcim.choices import DeviceStatusChoices, SiteStatusChoices
    from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site
    from extras.scripts import *


    class NewBranchScript(Script):

        class Meta:
            name = "New Branch"
            description = "Provision a new branch site"
            field_order = ['site_name', 'switch_count', 'switch_model']

        site_name = StringVar(
            description="Name of the new site"
        )
        switch_count = IntegerVar(
            description="Number of access switches to create"
        )
        manufacturer = ObjectVar(
            model=Manufacturer,
            required=False
        )
        switch_model = ObjectVar(
            description="Access switch model",
            model=DeviceType,
            query_params={
                'manufacturer_id': '$manufacturer'
            }
        )

        def run(self, data, commit):

            # Create the new site
            site = Site(
                name=data['site_name'],
                slug=slugify(data['site_name']),
                status=SiteStatusChoices.STATUS_PLANNED
            )
            site.save()
            self.log_success(f"Created new site: {site}")

            # Create access switches
            switch_role = DeviceRole.objects.get(name='Access Switch')
            for i in range(1, data['switch_count'] + 1):
                switch = Device(
                    device_type=data['switch_model'],
                    name=f'{site.slug}-switch{i}',
                    site=site,
                    status=DeviceStatusChoices.STATUS_PLANNED,
                    device_role=switch_role
                )
                switch.save()
                self.log_success(f"Created new switch: {switch}")

            # Generate a CSV table of new devices
            output = [
                'name,make,model'
            ]
            for switch in Device.objects.filter(site=site):
                attrs = [
                    switch.name,
                    switch.device_type.manufacturer.name,
                    switch.device_type.model
                ]
                output.append(','.join(attrs))

            return '\n'.join(output)

kind: ConfigMap
metadata:
  name: docsscript
  namespace: netbox

1.2. Mount the script in the values.yaml file:

## Additional volumes to mount
extraVolumeMounts:
 - name: docsscript
   mountPath: "/opt/netbox/netbox/scripts"
   readOnly: true

extraVolumes:
 - name: docsscript
   configMap:
     name: docsscript

  1. Run the script via GUI or API using any input values.

Expected Behavior

The script should execute and show the output (any output) on the screen.

Observed Behavior

The script is stuck at "Results pending...", returns no output and makes no database changes.

GUI:
image

API (35 minutes have passed):
image

I initially tested it with a very simple "Hello World" script which took no input data and was supposed to log a string and return another, but I observed the same behavior.

I logged in directly to the Kubernetes pod and executed the script via CLI using the following command:
/opt/netbox/venv/bin/python3 manage.py runscript --data '{"site_name": "TEST", "switch_count": 1, "switch_model": 1}' docsscript.NewBranchScript

Though the script returned an error (because I don't have the necessary roles and objects set in place) the results from the CLI appeared in the GUI. I'm positive these are from the CLI because I used different input data in the GUI.

image

I turned on Django logging to see whether the app reports any errors and here's what I've got:

Exception while resolving variable 'request' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [request] in [{'True': True, 'False': False, 'None': None}, {'options': [{'label': 'All Objects', 'items': []}, {'label': 'Circuits', 'items': [{'label': 'Providers', 'value': 'provider'}, {'label': 'Circuits', 'value': 'circuit'}]}, {'label': 'DCIM', 'items': [{'label': 'Sites', 'value': 'site'}, {'label': 'Racks', 'value': 'rack'}, {'label': 'Rack reservations', 'value': 'rackreservation'}, {'label': 'Locations', 'value': 'location'}, {'label': 'Device Types', 'value': 'devicetype'}, {'label': 'Devices', 'value': 'device'}, {'label': 'Virtual chassis', 'value': 'virtualchassis'}, {'label': 'Cables', 'value': 'cable'}, {'label': 'Power feeds', 'value': 'powerfeed'}]}, {'label': 'IPAM', 'items': [{'label': 'VRFs', 'value': 'vrf'}, {'label': 'Aggregates', 'value': 'aggregate'}, {'label': 'Prefixes', 'value': 'prefix'}, {'label': 'IP Addresses', 'value': 'ipaddress'}, {'label': 'VLANs', 'value': 'vlan'}]}, {'label': 'Tenancy', 'items': [{'label': 'Tenants', 'value': 'tenant'}]}, {'label': 'Virtualization', 'items': [{'label': 'Clusters', 'value': 'cluster'}, {'label': 'Virtual Machines', 'value': 'virtualmachine'}]}], 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>}]
Exception while resolving variable 'value' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
KeyError: 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'dict' object has no attribute 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [value] in {'label': 'All Objects', 'items': []}
Exception while resolving variable 'request' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'request'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [request] in [{'True': True, 'False': False, 'None': None}, {'options': [{'label': 'All Objects', 'items': []}, {'label': 'Circuits', 'items': [{'label': 'Providers', 'value': 'provider'}, {'label': 'Circuits', 'value': 'circuit'}]}, {'label': 'DCIM', 'items': [{'label': 'Sites', 'value': 'site'}, {'label': 'Racks', 'value': 'rack'}, {'label': 'Rack reservations', 'value': 'rackreservation'}, {'label': 'Locations', 'value': 'location'}, {'label': 'Device Types', 'value': 'devicetype'}, {'label': 'Devices', 'value': 'device'}, {'label': 'Virtual chassis', 'value': 'virtualchassis'}, {'label': 'Cables', 'value': 'cable'}, {'label': 'Power feeds', 'value': 'powerfeed'}]}, {'label': 'IPAM', 'items': [{'label': 'VRFs', 'value': 'vrf'}, {'label': 'Aggregates', 'value': 'aggregate'}, {'label': 'Prefixes', 'value': 'prefix'}, {'label': 'IP Addresses', 'value': 'ipaddress'}, {'label': 'VLANs', 'value': 'vlan'}]}, {'label': 'Tenancy', 'items': [{'label': 'Tenants', 'value': 'tenant'}]}, {'label': 'Virtualization', 'items': [{'label': 'Clusters', 'value': 'cluster'}, {'label': 'Virtual Machines', 'value': 'virtualmachine'}]}], 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>}]
Exception while resolving variable 'value' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
KeyError: 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'dict' object has no attribute 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'value'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [value] in {'label': 'All Objects', 'items': []}
Exception while resolving variable 'form' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [form] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>, 'request': <WSGIRequest: GET '/extras/scripts/results/14/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: admin>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ffa2b9bcd00>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ffa2b8bb490>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">, 'config': <netbox.config.Config object at 0x7ffa2b8507f0>, 'registry': {'model_features': {'custom_fields': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'custom_links': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'export_templates': defaultdict(<class 'list'>, {'extras': ['tag', 'customfield', 'webhook', 'customlink', 'exporttemplate'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'job_results': defaultdict(<class 'list'>, {'extras': ['script', 'report']}), 'tags': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'webhooks': defaultdict(<class 'list'>, {'extras': ['tag', 'configcontext', 'customfield', 'webhook', 'customlink', 'exporttemplate', 'imageattachment', 'journalentry'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'consoleporttemplate', 'consoleserverporttemplate', 'powerporttemplate', 'poweroutlettemplate', 'interfacetemplate', 'frontporttemplate', 'rearporttemplate', 'devicebaytemplate', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'circuittermination', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'fhrpgroupassignment', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'contactassignment', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']})}, 'plugin_template_extensions': defaultdict(<class 'list'>, {}), 'plugin_menu_items': {}}, 'preferences': <UserConfig: UserConfig object (1)>}, {}, {'script': <docsscript.NewBranchScript object at 0x7ffa2b8bb4f0>, 'result': <JobResult: 4ee69b76-89e9-444d-911b-528507a2c4d2>, 'class_name': 'NewBranchScript'}, {}]
Exception while resolving variable 'form' in template 'extras/script_result.html'.
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'form'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup
    raise VariableDoesNotExist("Failed lookup for key "
django.template.base.VariableDoesNotExist: Failed lookup for key [form] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>, 'request': <WSGIRequest: GET '/extras/scripts/results/14/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: admin>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ffa2b9bcd00>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ffa2b8bb490>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">, 'config': <netbox.config.Config object at 0x7ffa2b8507f0>, 'registry': {'model_features': {'custom_fields': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'custom_links': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'export_templates': defaultdict(<class 'list'>, {'extras': ['tag', 'customfield', 'webhook', 'customlink', 'exporttemplate'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'job_results': defaultdict(<class 'list'>, {'extras': ['script', 'report']}), 'tags': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'webhooks': defaultdict(<class 'list'>, {'extras': ['tag', 'configcontext', 'customfield', 'webhook', 'customlink', 'exporttemplate', 'imageattachment', 'journalentry'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'consoleporttemplate', 'consoleserverporttemplate', 'powerporttemplate', 'poweroutlettemplate', 'interfacetemplate', 'frontporttemplate', 'rearporttemplate', 'devicebaytemplate', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'circuittermination', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'fhrpgroupassignment', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'contactassignment', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']})}, 'plugin_template_extensions': defaultdict(<class 'list'>, {}), 'plugin_menu_items': {}}, 'preferences': <UserConfig: UserConfig object (1)>}, {}, {'script': <docsscript.NewBranchScript object at 0x7ffa2b8bb4f0>, 'result': <JobResult: 4ee69b76-89e9-444d-911b-528507a2c4d2>, 'class_name': 'NewBranchScript'}, {}]

Please let me know if you need any additional information.

Originally created by @pn-pn on GitHub (Jan 24, 2022). ### NetBox version v3.1.6 ### Python version 3.9 ### Steps to Reproduce 1. Launch Netbox in Kubernetes using Helm: https://github.com/bootc/netbox-chart/blob/master/values.yaml and the official Docker image "netboxcommunity/netbox:v3.1-ldap" (although I'd try to reproduce this issue in any Kubernetes or Docker environment first) 1.1. Create a configmap with the custom script presented in the docs (https://netbox.readthedocs.io/en/stable/customization/custom-scripts/): ``` apiVersion: v1 data: docsscript.py: |+ from django.utils.text import slugify from dcim.choices import DeviceStatusChoices, SiteStatusChoices from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Site from extras.scripts import * class NewBranchScript(Script): class Meta: name = "New Branch" description = "Provision a new branch site" field_order = ['site_name', 'switch_count', 'switch_model'] site_name = StringVar( description="Name of the new site" ) switch_count = IntegerVar( description="Number of access switches to create" ) manufacturer = ObjectVar( model=Manufacturer, required=False ) switch_model = ObjectVar( description="Access switch model", model=DeviceType, query_params={ 'manufacturer_id': '$manufacturer' } ) def run(self, data, commit): # Create the new site site = Site( name=data['site_name'], slug=slugify(data['site_name']), status=SiteStatusChoices.STATUS_PLANNED ) site.save() self.log_success(f"Created new site: {site}") # Create access switches switch_role = DeviceRole.objects.get(name='Access Switch') for i in range(1, data['switch_count'] + 1): switch = Device( device_type=data['switch_model'], name=f'{site.slug}-switch{i}', site=site, status=DeviceStatusChoices.STATUS_PLANNED, device_role=switch_role ) switch.save() self.log_success(f"Created new switch: {switch}") # Generate a CSV table of new devices output = [ 'name,make,model' ] for switch in Device.objects.filter(site=site): attrs = [ switch.name, switch.device_type.manufacturer.name, switch.device_type.model ] output.append(','.join(attrs)) return '\n'.join(output) kind: ConfigMap metadata: name: docsscript namespace: netbox ``` 1.2. Mount the script in the values.yaml file: ``` ## Additional volumes to mount extraVolumeMounts: - name: docsscript mountPath: "/opt/netbox/netbox/scripts" readOnly: true extraVolumes: - name: docsscript configMap: name: docsscript ``` 2. Run the script via GUI or API using any input values. ### Expected Behavior The script should execute and show the output (any output) on the screen. ### Observed Behavior The script is stuck at "Results pending...", returns no output and makes no database changes. GUI: ![image](https://user-images.githubusercontent.com/64140818/150753036-226f1bff-10c2-458a-9f1c-b479391f0116.png) API (35 minutes have passed): ![image](https://user-images.githubusercontent.com/64140818/150759269-5033b6b0-85c4-41ad-aafc-4bf6681c7fc4.png) I initially tested it with a very simple "Hello World" script which took no input data and was supposed to log a string and return another, but I observed the same behavior. I logged in directly to the Kubernetes pod and executed the script via CLI using the following command: ```/opt/netbox/venv/bin/python3 manage.py runscript --data '{"site_name": "TEST", "switch_count": 1, "switch_model": 1}' docsscript.NewBranchScript``` Though the script returned an error (because I don't have the necessary roles and objects set in place) the results from the CLI appeared in the GUI. I'm positive these are from the CLI because I used different input data in the GUI. ![image](https://user-images.githubusercontent.com/64140818/150757588-b03b5fe2-ab8a-4506-a748-07fbb7caacb0.png) I turned on Django logging to see whether the app reports any errors and here's what I've got: ``` Exception while resolving variable 'request' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [request] in [{'True': True, 'False': False, 'None': None}, {'options': [{'label': 'All Objects', 'items': []}, {'label': 'Circuits', 'items': [{'label': 'Providers', 'value': 'provider'}, {'label': 'Circuits', 'value': 'circuit'}]}, {'label': 'DCIM', 'items': [{'label': 'Sites', 'value': 'site'}, {'label': 'Racks', 'value': 'rack'}, {'label': 'Rack reservations', 'value': 'rackreservation'}, {'label': 'Locations', 'value': 'location'}, {'label': 'Device Types', 'value': 'devicetype'}, {'label': 'Devices', 'value': 'device'}, {'label': 'Virtual chassis', 'value': 'virtualchassis'}, {'label': 'Cables', 'value': 'cable'}, {'label': 'Power feeds', 'value': 'powerfeed'}]}, {'label': 'IPAM', 'items': [{'label': 'VRFs', 'value': 'vrf'}, {'label': 'Aggregates', 'value': 'aggregate'}, {'label': 'Prefixes', 'value': 'prefix'}, {'label': 'IP Addresses', 'value': 'ipaddress'}, {'label': 'VLANs', 'value': 'vlan'}]}, {'label': 'Tenancy', 'items': [{'label': 'Tenants', 'value': 'tenant'}]}, {'label': 'Virtualization', 'items': [{'label': 'Clusters', 'value': 'cluster'}, {'label': 'Virtual Machines', 'value': 'virtualmachine'}]}], 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>}] Exception while resolving variable 'value' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] KeyError: 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup current = getattr(current, bit) AttributeError: 'dict' object has no attribute 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [value] in {'label': 'All Objects', 'items': []} Exception while resolving variable 'request' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'request' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [request] in [{'True': True, 'False': False, 'None': None}, {'options': [{'label': 'All Objects', 'items': []}, {'label': 'Circuits', 'items': [{'label': 'Providers', 'value': 'provider'}, {'label': 'Circuits', 'value': 'circuit'}]}, {'label': 'DCIM', 'items': [{'label': 'Sites', 'value': 'site'}, {'label': 'Racks', 'value': 'rack'}, {'label': 'Rack reservations', 'value': 'rackreservation'}, {'label': 'Locations', 'value': 'location'}, {'label': 'Device Types', 'value': 'devicetype'}, {'label': 'Devices', 'value': 'device'}, {'label': 'Virtual chassis', 'value': 'virtualchassis'}, {'label': 'Cables', 'value': 'cable'}, {'label': 'Power feeds', 'value': 'powerfeed'}]}, {'label': 'IPAM', 'items': [{'label': 'VRFs', 'value': 'vrf'}, {'label': 'Aggregates', 'value': 'aggregate'}, {'label': 'Prefixes', 'value': 'prefix'}, {'label': 'IP Addresses', 'value': 'ipaddress'}, {'label': 'VLANs', 'value': 'vlan'}]}, {'label': 'Tenancy', 'items': [{'label': 'Tenants', 'value': 'tenant'}]}, {'label': 'Virtualization', 'items': [{'label': 'Clusters', 'value': 'cluster'}, {'label': 'Virtual Machines', 'value': 'virtualmachine'}]}], 'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>}] Exception while resolving variable 'value' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] KeyError: 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup current = getattr(current, bit) AttributeError: 'dict' object has no attribute 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'value' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [value] in {'label': 'All Objects', 'items': []} Exception while resolving variable 'form' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [form] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>, 'request': <WSGIRequest: GET '/extras/scripts/results/14/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: admin>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ffa2b9bcd00>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ffa2b8bb490>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">, 'config': <netbox.config.Config object at 0x7ffa2b8507f0>, 'registry': {'model_features': {'custom_fields': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'custom_links': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'export_templates': defaultdict(<class 'list'>, {'extras': ['tag', 'customfield', 'webhook', 'customlink', 'exporttemplate'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'job_results': defaultdict(<class 'list'>, {'extras': ['script', 'report']}), 'tags': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'webhooks': defaultdict(<class 'list'>, {'extras': ['tag', 'configcontext', 'customfield', 'webhook', 'customlink', 'exporttemplate', 'imageattachment', 'journalentry'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'consoleporttemplate', 'consoleserverporttemplate', 'powerporttemplate', 'poweroutlettemplate', 'interfacetemplate', 'frontporttemplate', 'rearporttemplate', 'devicebaytemplate', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'circuittermination', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'fhrpgroupassignment', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'contactassignment', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']})}, 'plugin_template_extensions': defaultdict(<class 'list'>, {}), 'plugin_menu_items': {}}, 'preferences': <UserConfig: UserConfig object (1)>}, {}, {'script': <docsscript.NewBranchScript object at 0x7ffa2b8bb4f0>, 'result': <JobResult: 4ee69b76-89e9-444d-911b-528507a2c4d2>, 'class_name': 'NewBranchScript'}, {}] Exception while resolving variable 'form' in template 'extras/script_result.html'. Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup current = current[bit] File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 835, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 843, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'form' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/django/template/base.py", line 848, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key " django.template.base.VariableDoesNotExist: Failed lookup for key [form] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ffa2b96d4c0>>, 'request': <WSGIRequest: GET '/extras/scripts/results/14/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: admin>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ffa2b9bcd00>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ffa2b8bb490>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">, 'config': <netbox.config.Config object at 0x7ffa2b8507f0>, 'registry': {'model_features': {'custom_fields': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'custom_links': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'export_templates': defaultdict(<class 'list'>, {'extras': ['tag', 'customfield', 'webhook', 'customlink', 'exporttemplate'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'job_results': defaultdict(<class 'list'>, {'extras': ['script', 'report']}), 'tags': defaultdict(<class 'list'>, {'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']}), 'webhooks': defaultdict(<class 'list'>, {'extras': ['tag', 'configcontext', 'customfield', 'webhook', 'customlink', 'exporttemplate', 'imageattachment', 'journalentry'], 'dcim': ['consoleport', 'consoleserverport', 'powerport', 'poweroutlet', 'interface', 'frontport', 'rearport', 'devicebay', 'inventoryitem', 'manufacturer', 'devicetype', 'devicerole', 'platform', 'device', 'virtualchassis', 'cable', 'consoleporttemplate', 'consoleserverporttemplate', 'powerporttemplate', 'poweroutlettemplate', 'interfacetemplate', 'frontporttemplate', 'rearporttemplate', 'devicebaytemplate', 'powerpanel', 'powerfeed', 'rackrole', 'rack', 'rackreservation', 'region', 'sitegroup', 'site', 'location'], 'circuits': ['circuittype', 'circuit', 'circuittermination', 'provider', 'providernetwork'], 'ipam': ['fhrpgroup', 'fhrpgroupassignment', 'rir', 'asn', 'aggregate', 'role', 'prefix', 'iprange', 'ipaddress', 'service', 'vlangroup', 'vlan', 'vrf', 'routetarget'], 'virtualization': ['clustertype', 'clustergroup', 'cluster', 'virtualmachine', 'vminterface'], 'tenancy': ['contactgroup', 'contactrole', 'contact', 'contactassignment', 'tenantgroup', 'tenant'], 'wireless': ['wirelesslangroup', 'wirelesslan', 'wirelesslink']})}, 'plugin_template_extensions': defaultdict(<class 'list'>, {}), 'plugin_menu_items': {}}, 'preferences': <UserConfig: UserConfig object (1)>}, {}, {'script': <docsscript.NewBranchScript object at 0x7ffa2b8bb4f0>, 'result': <JobResult: 4ee69b76-89e9-444d-911b-528507a2c4d2>, 'class_name': 'NewBranchScript'}, {}] ``` Please let me know if you need any additional information.
adam added the type: bug label 2025-12-29 19:35:24 +01:00
adam closed this issue 2025-12-29 19:35:24 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Jan 24, 2022):

Did you mount the scripts in both the netbox and the worker deployments?

https://github.com/bootc/netbox-chart/blob/master/values.yaml#L541-L550

https://github.com/bootc/netbox-chart/blob/master/values.yaml#L703-L712

The netbox deployment schedules the script and the worker executes it. Both need to load the script from the filesystem.

@kkthxbye-code commented on GitHub (Jan 24, 2022): Did you mount the scripts in both the netbox and the worker deployments? https://github.com/bootc/netbox-chart/blob/master/values.yaml#L541-L550 https://github.com/bootc/netbox-chart/blob/master/values.yaml#L703-L712 The netbox deployment schedules the script and the worker executes it. Both need to load the script from the filesystem.
Author
Owner

@pn-pn commented on GitHub (Jan 24, 2022):

Works great now. Thank you.

@pn-pn commented on GitHub (Jan 24, 2022): Works great now. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5991