Possible bug with tenant record generation #2034

Closed
opened 2025-12-29 17:21:38 +01:00 by adam · 3 comments
Owner

Originally created by @unquietwiki on GitHub (Sep 28, 2018).

  • Python version: 3.6.6
  • NetBox version: 2.4.5-dev

Steps to Reproduce

  1. Have a tenant record of some kind.
  2. Attempt to make changes to any data record, whether the tenant is actually used in it, or not.

Expected Behavior

Data records successfully updated.

Observed Behavior

Intermittent failure of records to be added. Moving my databases to a separate VM seem to have helped. The tenant feature isn't critical to my use, so I've removed the references that I did use. This was happening in the last stable version too. The only reason I was able to pin this down to a Tenant entry, was the name that kept coming up as a missing index.

Log fragment 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_look$
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [disabled] in 'TENANTNAME'
Exception while resolving variable 'label' in template 'django/forms/widgets/select.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_look$
    current = current[bit]
TypeError: string indices must be integers

Log fragment 2

  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 841, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'return_url'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'return_url'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [return_url] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: 'fCXySqReBAyEvPpKABVpF6N4TqrSDuvcd3wS1CxMfvQSwoBkxFs72SC14s0gbn3K'>, 'request': <WSGIRequest: GET '/tenancy/tenants/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: michael>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7fbc56585e48>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7fbc5677ada0>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">}, {}, {'content_type': <ContentType: tenant>, 'table': <tenancy.tables.TenantTable object at 0x7fbc56587fd0>, 'permissions': {'add': True, 'change': True, 'delete': True}, 'filter_form': <TenantFilterForm bound=True, valid=Unknown, fields=(q;group)>, 'tags': <QuerySet []>}, {'block': <Block Node: content. Contents: [<TextNode: '\n<div class="pull-right">'>, <IfNode>, <TextNode: '\n    '>, <django.template.library.InclusionNode object at 0x7fbc56695da0>, <TextNode: '\n</div>\n<h1>'>, <Block Node: title. Contents: [<TextNode: 'Tenants'>]>, <TextNode: '</h1>\n<div class="row">\n\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699908>, <TextNode: '\n    </div>\n    <div clas'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699978>, <TextNode: '\n\t\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699a20>, <TextNode: '\n    </div>\n</div>\n'>]>}, {'bulk_edit_url': 'tenancy:tenant_bulk_edit', 'bulk_delete_url': 'tenancy:tenant_bulk_delete'}]
Exception while resolving variable 'table_template' in template 'tenancy/tenant_list.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_lookup
    current = current[bit]
  File "/usr/local/lib/python3.6/dist-packages/django/template/context.py", line 83, in __getitem__
    raise KeyError(key)
KeyError: 'table_template'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 841, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(type(current), bit):
AttributeError: type object 'RequestContext' has no attribute 'table_template'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'table_template'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [table_template] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: 'fCXySqReBAyEvPpKABVpF6N4TqrSDuvcd3wS1CxMfvQSwoBkxFs72SC14s0gbn3K'>, 'request': <WSGIRequest: GET '/tenancy/tenants/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: michael>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7fbc56585e48>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7fbc5677ada0>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">}, {}, {'content_type': <ContentType: tenant>, 'table': <tenancy.tables.TenantTable object at 0x7fbc56587fd0>, 'permissions': {'add': True, 'change': True, 'delete': True}, 'filter_form': <TenantFilterForm bound=True, valid=Unknown, fields=(q;group)>, 'tags': <QuerySet []>}, {'block': <Block Node: content. Contents: [<TextNode: '\n<div class="pull-right">'>, <IfNode>, <TextNode: '\n    '>, <django.template.library.InclusionNode object at 0x7fbc56695da0>, <TextNode: '\n</div>\n<h1>'>, <Block Node: title. Contents: [<TextNode: 'Tenants'>]>, <TextNode: '</h1>\n<div class="row">\n\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699908>, <TextNode: '\n    </div>\n    <div clas'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699978>, <TextNode: '\n\t\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699a20>, <TextNode: '\n    </div>\n</div>\n'>]>}, {'bulk_edit_url': 'tenancy:tenant_bulk_edit', 'bulk_delete_url': 'tenancy:tenant_bulk_delete'}]
Exception while resolving variable 'q' in template 'tenancy/tenant_list.html'.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/utils/datastructures.py", line 77, in __getitem__
    list_ = super().__getitem__(key)
KeyError: 'q'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_lookup
    current = current[bit]
  File "/usr/local/lib/python3.6/dist-packages/django/utils/datastructures.py", line 79, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'q'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 843, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'QueryDict' object has no attribute 'q'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup
    current = current[int(bit)]
ValueError: invalid literal for int() with base 10: 'q'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup
    (bit, current))  # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [q] in <QueryDict: {}>
Originally created by @unquietwiki on GitHub (Sep 28, 2018). * Python version: 3.6.6 * NetBox version: 2.4.5-dev ### Steps to Reproduce 1. Have a tenant record of some kind. 2. Attempt to make changes to any data record, whether the tenant is actually used in it, or not. <!-- What did you expect to happen? --> ### Expected Behavior Data records successfully updated. <!-- What happened instead? --> ### Observed Behavior Intermittent failure of records to be added. Moving my databases to a separate VM seem to have helped. The tenant feature isn't critical to my use, so I've removed the references that I did use. This was happening in the last stable version too. The only reason I was able to pin this down to a Tenant entry, was the name that kept coming up as a missing index. **Log fragment 1** ``` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_look$ (bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [disabled] in 'TENANTNAME' Exception while resolving variable 'label' in template 'django/forms/widgets/select.html'. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_look$ current = current[bit] TypeError: string indices must be integers ``` **Log fragment 2** ``` File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 841, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'return_url' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'return_url' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup (bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [return_url] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: 'fCXySqReBAyEvPpKABVpF6N4TqrSDuvcd3wS1CxMfvQSwoBkxFs72SC14s0gbn3K'>, 'request': <WSGIRequest: GET '/tenancy/tenants/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: michael>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7fbc56585e48>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7fbc5677ada0>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">}, {}, {'content_type': <ContentType: tenant>, 'table': <tenancy.tables.TenantTable object at 0x7fbc56587fd0>, 'permissions': {'add': True, 'change': True, 'delete': True}, 'filter_form': <TenantFilterForm bound=True, valid=Unknown, fields=(q;group)>, 'tags': <QuerySet []>}, {'block': <Block Node: content. Contents: [<TextNode: '\n<div class="pull-right">'>, <IfNode>, <TextNode: '\n '>, <django.template.library.InclusionNode object at 0x7fbc56695da0>, <TextNode: '\n</div>\n<h1>'>, <Block Node: title. Contents: [<TextNode: 'Tenants'>]>, <TextNode: '</h1>\n<div class="row">\n\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699908>, <TextNode: '\n </div>\n <div clas'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699978>, <TextNode: '\n\t\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699a20>, <TextNode: '\n </div>\n</div>\n'>]>}, {'bulk_edit_url': 'tenancy:tenant_bulk_edit', 'bulk_delete_url': 'tenancy:tenant_bulk_delete'}] Exception while resolving variable 'table_template' in template 'tenancy/tenant_list.html'. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_lookup current = current[bit] File "/usr/local/lib/python3.6/dist-packages/django/template/context.py", line 83, in __getitem__ raise KeyError(key) KeyError: 'table_template' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 841, in _resolve_lookup if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'table_template' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'table_template' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup (bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [table_template] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: 'fCXySqReBAyEvPpKABVpF6N4TqrSDuvcd3wS1CxMfvQSwoBkxFs72SC14s0gbn3K'>, 'request': <WSGIRequest: GET '/tenancy/tenants/'>, 'MEDIA_URL': '/media/', 'user': <SimpleLazyObject: <User: michael>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7fbc56585e48>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7fbc5677ada0>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}, 'settings': <LazySettings "netbox.settings">}, {}, {'content_type': <ContentType: tenant>, 'table': <tenancy.tables.TenantTable object at 0x7fbc56587fd0>, 'permissions': {'add': True, 'change': True, 'delete': True}, 'filter_form': <TenantFilterForm bound=True, valid=Unknown, fields=(q;group)>, 'tags': <QuerySet []>}, {'block': <Block Node: content. Contents: [<TextNode: '\n<div class="pull-right">'>, <IfNode>, <TextNode: '\n '>, <django.template.library.InclusionNode object at 0x7fbc56695da0>, <TextNode: '\n</div>\n<h1>'>, <Block Node: title. Contents: [<TextNode: 'Tenants'>]>, <TextNode: '</h1>\n<div class="row">\n\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699908>, <TextNode: '\n </div>\n <div clas'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699978>, <TextNode: '\n\t\t'>, <django.template.loader_tags.IncludeNode object at 0x7fbc56699a20>, <TextNode: '\n </div>\n</div>\n'>]>}, {'bulk_edit_url': 'tenancy:tenant_bulk_edit', 'bulk_delete_url': 'tenancy:tenant_bulk_delete'}] Exception while resolving variable 'q' in template 'tenancy/tenant_list.html'. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/utils/datastructures.py", line 77, in __getitem__ list_ = super().__getitem__(key) KeyError: 'q' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 835, in _resolve_lookup current = current[bit] File "/usr/local/lib/python3.6/dist-packages/django/utils/datastructures.py", line 79, in __getitem__ raise MultiValueDictKeyError(key) django.utils.datastructures.MultiValueDictKeyError: 'q' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 843, in _resolve_lookup current = getattr(current, bit) AttributeError: 'QueryDict' object has no attribute 'q' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 849, in _resolve_lookup current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'q' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/template/base.py", line 856, in _resolve_lookup (bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [q] in <QueryDict: {}> ```
adam closed this issue 2025-12-29 17:21:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 28, 2018):

NetBox version: 2.4.5-dev

Please ensure you're testing using only the latest stable release. The development branch is always in flux.

Have a tenant record of some kind.
Attempt to make changes to any data record, whether the tenant is actually used in it, or not.

Please detail the specific steps one can take to recreate this issue.

@jeremystretch commented on GitHub (Sep 28, 2018): > NetBox version: 2.4.5-dev Please ensure you're testing using only the latest stable release. The development branch is always in flux. > Have a tenant record of some kind. > Attempt to make changes to any data record, whether the tenant is actually used in it, or not. Please detail the _specific_ steps one can take to recreate this issue.
Author
Owner

@jeremystretch commented on GitHub (Oct 5, 2018):

Closed due to lack of activity.

@jeremystretch commented on GitHub (Oct 5, 2018): Closed due to lack of activity.
Author
Owner

@unquietwiki commented on GitHub (Oct 5, 2018):

@jeremystretch Sorry I didn't get back to you on it. Since I offloaded the database activity out of the container, and had deleted that tenant record; the instance has been rather snappy. I've been rather busy at the office to offer further debugging on it. Thank you for your patience again.

@unquietwiki commented on GitHub (Oct 5, 2018): @jeremystretch Sorry I didn't get back to you on it. Since I offloaded the database activity out of the container, and had deleted that tenant record; the instance has been rather snappy. I've been rather busy at the office to offer further debugging on it. Thank you for your patience again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2034