Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing a custom script raises an AttributeError #15789

Closed
jeremystretch opened this issue Apr 19, 2024 · 0 comments
Closed

Executing a custom script raises an AttributeError #15789

jeremystretch opened this issue Apr 19, 2024 · 0 comments
Assignees
Labels
beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jeremystretch
Copy link
Member

Deployment Type

NetBox Cloud

NetBox Version

v4.0-beta1

Python Version

3.10

Steps to Reproduce

  1. Upload a functional custom script
  2. Attempt to execute the script, either immediately or at a scheduled time

Expected Behavior

The script should execute successfully.

Observed Behavior

An AttributeError exception is raised:

Template error:
In template /home/jstretch/projects/netbox/netbox/templates/extras/script_result.html, error at line 104
   'NoneType' object has no attribute 'available_columns'
   94 :     {% if filter_form %}
   95 :       <div class="tab-pane show" id="filters-form" role="tabpanel" aria-labelledby="filters-form-tab">
   96 :         {% include 'inc/filter_list.html' %}
   97 :       </div>
   98 :     {% endif %}
   99 :     {# /Filters tab #}
   100 : 
   101 : {% endblock content %}
   102 : 
   103 : {% block modals %}
   104 :    {% table_config_form table table_name="ObjectTable" %} 
   105 : {% endblock modals %}
   106 : 

Traceback (most recent call last):
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/utilities/views.py", line 108, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/jstretch/projects/netbox/netbox/extras/views.py", line 1234, in get
    return render(request, 'extras/script_result.html', context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/shortcuts.py", line 25, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 159, in render
    return compiled_parent._render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 159, in render
    return compiled_parent._render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 159, in render
    return compiled_parent._render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/home/jstretch/projects/netbox/venv/lib/python3.10/site-packages/django/template/library.py", line 258, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "/home/jstretch/projects/netbox/netbox/utilities/templatetags/helpers.py", line 261, in table_config_form
    'form': TableConfigForm(table=table),
  File "/home/jstretch/projects/netbox/netbox/utilities/forms/forms.py", line 129, in __init__
    self.fields['available_columns'].choices = table.available_columns

Exception Type: AttributeError at /extras/scripts/results/4/
Exception Value: 'NoneType' object has no attribute 'available_columns'

This appears to be a problem only upon the initial execution: Navigating directly to the script's result then succeeds without error.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide labels Apr 19, 2024
@arthanson arthanson self-assigned this Apr 19, 2024
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label Apr 19, 2024
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Apr 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants