pythonpython-3.xattributeerrornetbox

'str' object has no attribute 'label' - AttributeError


I upgraded NetBox from version 2.11.7 to version 3.3.9 recently. As in the new version there is no longer a password vault, it was necessary to install the netbox-secretstore plugin. The entire NetBox update and plugin installation went well, including the migration of the passwords I already had, but when I add a new credential or edit an existing credential I get the following error:

error

I've already searched GitHub for both solutions (NetBox and netbox-secretstore) and apparently no one had this problem.

Here are the collected logs:

2022-12-29 07:26:02,736 django.request ERROR: Internal Server Error: /plugins/netbox_secretstore/secrets/add/
Traceback (most recent call last):
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 84, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/netbox_secretstore/views.py", line 128, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 303, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 90, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/views/generic/base.py", line 119, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 357, in get
    return render(request, self.template_name, {
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/shortcuts.py", line 24, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/backends/django.py", line 62, in render
    return self.template.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/test/utils.py", line 111, in instrumented_test_render
    return self.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/opt/netbox-3.3.9/venv/lib64/python3.8/site-packages/django/template/library.py", line 260, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "/opt/netbox/netbox/utilities/templatetags/form_helpers.py", line 43, in render_field
    'label': label or field.label,
AttributeError: 'str' object has no attribute 'label'

As I don't know the structure of the application very well, I would like you to help me how to proceed.

Thanks in advance! Best regards.

EDIT 1:

When i comment the label on return in "/opt/netbox/netbox/utilities/templatetags/form_helpers.py" the pages opens but without labels, see:

label

without labels

What is wrong?


Solution

  • Solutioned.

    On netbox_secretstore/templates/netbox_secretstore/secret_edit.html, remove the follow line:

        {% endwith %}
        {% render_field form.role %}
        {% render_field form.name %}
      - {% render_field form.userkeys %}
        {% render_field form.tags %}
        </div>
    </div>