Staging instance, all changes can be removed at any time

Skip to content

browse/templates/top-navigation: Prevent VariableDoesNotExist exception

It exist cases where the vault_cooking template variable is set to None (when browsing a snapshot branch targeting a content for instance), so ensure to prevent VariableDoesNotExist exception thrown by django in debug mode as it generates noise in debug output.

[04/Nov/2022 15:40:58] [DEBUG] chardet.universaldetector.close:271 - no data received!
[04/Nov/2022 15:40:58] [DEBUG] chardet.universaldetector.close:309 - no probers hit minimum threshold
[04/Nov/2022 15:40:58] [INFO] "GET /browse/origin/?origin_url=https://elpa.gnu.org/packages/filladapt-2.12.2.el HTTP/1.1" 302 0
[04/Nov/2022 15:40:58] [DEBUG] chardet.universaldetector.close:271 - no data received!
[04/Nov/2022 15:40:58] [DEBUG] chardet.universaldetector.close:309 - no probers hit minimum threshold
[04/Nov/2022 15:40:58] [INFO] "GET /browse/origin/directory/?origin_url=https://elpa.gnu.org/packages/filladapt-2.12.2.el HTTP/1.1" 302 0
[04/Nov/2022 15:40:58] [DEBUG] Exception while resolving variable 'directory_context' in template 'browse-content.html'.
Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'directory_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/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: 'directory_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/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 [directory_context] in None
[04/Nov/2022 15:40:58] [DEBUG] Exception while resolving variable 'revision_context' in template 'browse-content.html'.
Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/lib/python3.9/site-packages/django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/lib/python3.9/site-packages/django/template/base.py", line 837, in _resolve_lookup
    current = getattr(current, bit)
AttributeError: 'NoneType' object has no attribute 'revision_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/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: 'revision_context'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anlambert/.virtualenvs/swh/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 [revision_context] in None
[04/Nov/2022 15:40:58] [INFO] "GET /browse/content/sha1_git:cd0785946c9253d5b2179babc7d0dec3088b31c0/?origin_url=https://elpa.gnu.org/packages/filladapt-2.12.2.el HTTP/1.1" 200 17205

Depends on !948 (closed)


Migrated from D8816 (view on Phabricator)

Merge request reports

Loading