Failed to render jinja template on device #7827

Closed
opened 2025-12-29 20:28:43 +01:00 by adam · 1 comment
Owner

Originally created by @abhi1693 on GitHub (Mar 31, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.5-beta1

Python version

3.10

Steps to Reproduce

  1. Create a GIT datasource using https://github.com/jeremystretch/example-config-templates and sync
  2. Create a config template and choose the file roles/access-switch.j2
  3. Apply the config template on your device

Expected Behavior

The rendered config is shown

Observed Behavior

Traceback (most recent call last):
  File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/jinja2.py", line 23, in get_source
    template_source = self._template_cache[template]
KeyError: 'base.j2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/asaharan/PycharmProjects/netbox/netbox/dcim/views.py", line 2022, in get_extra_context
    rendered_config = config_template.render(context=context_data)
  File "/home/asaharan/PycharmProjects/netbox/netbox/extras/models/configs.py", line 249, in render
    output = template.render(**context)
  File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/jinja2.py", line 25, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: base.j2
Originally created by @abhi1693 on GitHub (Mar 31, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.5-beta1 ### Python version 3.10 ### Steps to Reproduce 1. Create a GIT datasource using https://github.com/jeremystretch/example-config-templates and sync 2. Create a config template and choose the file `roles/access-switch.j2` 3. Apply the config template on your device ### Expected Behavior The rendered config is shown ### Observed Behavior ``` Traceback (most recent call last): File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/jinja2.py", line 23, in get_source template_source = self._template_cache[template] KeyError: 'base.j2' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/asaharan/PycharmProjects/netbox/netbox/dcim/views.py", line 2022, in get_extra_context rendered_config = config_template.render(context=context_data) File "/home/asaharan/PycharmProjects/netbox/netbox/extras/models/configs.py", line 249, in render output = template.render(**context) File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/home/asaharan/PycharmProjects/netbox/venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "<template>", line 1, in top-level template code File "/home/asaharan/PycharmProjects/netbox/netbox/utilities/jinja2.py", line 25, in get_source raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: base.j2 ```
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 20:28:43 +01:00
adam closed this issue 2025-12-29 20:28:43 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 31, 2023):

Looks like this was caused by cleanup in 00088cb.

@jeremystretch commented on GitHub (Mar 31, 2023): Looks like this was caused by cleanup in 00088cb.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7827