Page MenuHomeSoftware Heritage

browse/templates/top-navigation: Prevent VariableDoesNotExist exception
ClosedPublic

Authored by anlambert on Nov 4 2022, 4:47 PM.

Details

Summary

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 D8814

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D8816 (id=31763)

Could not rebase; Attempt merge onto d055e08d8b...

Updating d055e08d..2fdb0b16
Fast-forward
 swh/web/browse/snapshot_context.py                 | 136 +++++++---
 swh/web/browse/templates/browse-branches.html      |   9 +-
 .../templates/includes/snapshot-context.html       |   6 +-
 .../browse/templates/includes/top-navigation.html  |   6 +-
 swh/web/tests/browse/test_snapshot_context.py      |  22 +-
 swh/web/tests/browse/views/test_content.py         |   8 +-
 swh/web/tests/browse/views/test_directory.py       |  12 +-
 swh/web/tests/browse/views/test_snapshot.py        | 295 +++++++++++++++++++--
 swh/web/tests/conftest.py                          |   4 +
 swh/web/tests/utils/test_archive.py                |   7 +-
 swh/web/utils/archive.py                           |   6 +
 swh/web/utils/typing.py                            |  10 +-
 12 files changed, 426 insertions(+), 95 deletions(-)
Changes applied before test
commit 2fdb0b164b2166bb820bae0f23580ef9b842330a
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 16:43:33 2022 +0100

    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.

commit f0f3e6890a2e081c2f868a8e9a6755cd952ae227
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 14:26:10 2022 +0100

    browse: Update snapshot branches list view to display all target types
    
    Previously, the snapshot branches list view was only displaying branches
    targeting revisions but it now exists cases where branches can target
    contents or directories.
    
    So update view implementation to display all type of branches and add
    visual clues to indicate which object types they are targeting.
    
    Related to T4669

commit 8f594ec2b6e2e60d49a53fc9ed72d1f3607d1a10
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Wed Nov 2 15:52:59 2022 +0100

    browse: Handle snapshots whose branches target contents or directories
    
    Previously swh-web was only supporting the browsing of snapshot branches
    targeting revisions but we recently introduced new Software Heritage
    loaders producing snapshots whose branches target contents or directories
    but no revisions.
    
    So add support to browse such snapshots as previously they were flagged as
    empty when trying to display them.
    
    Related to T4669

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2117/ for more details.

This revision is now accepted and ready to land.Nov 4 2022, 5:07 PM

Build has FAILED

Patch application report for D8816 (id=31763)

Could not rebase; Attempt merge onto d055e08d8b...

Updating d055e08d..2fdb0b16
Fast-forward
 swh/web/browse/snapshot_context.py                 | 136 +++++++---
 swh/web/browse/templates/browse-branches.html      |   9 +-
 .../templates/includes/snapshot-context.html       |   6 +-
 .../browse/templates/includes/top-navigation.html  |   6 +-
 swh/web/tests/browse/test_snapshot_context.py      |  22 +-
 swh/web/tests/browse/views/test_content.py         |   8 +-
 swh/web/tests/browse/views/test_directory.py       |  12 +-
 swh/web/tests/browse/views/test_snapshot.py        | 295 +++++++++++++++++++--
 swh/web/tests/conftest.py                          |   4 +
 swh/web/tests/utils/test_archive.py                |   7 +-
 swh/web/utils/archive.py                           |   6 +
 swh/web/utils/typing.py                            |  10 +-
 12 files changed, 426 insertions(+), 95 deletions(-)
Changes applied before test
commit 2fdb0b164b2166bb820bae0f23580ef9b842330a
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 16:43:33 2022 +0100

    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.

commit f0f3e6890a2e081c2f868a8e9a6755cd952ae227
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 14:26:10 2022 +0100

    browse: Update snapshot branches list view to display all target types
    
    Previously, the snapshot branches list view was only displaying branches
    targeting revisions but it now exists cases where branches can target
    contents or directories.
    
    So update view implementation to display all type of branches and add
    visual clues to indicate which object types they are targeting.
    
    Related to T4669

commit 8f594ec2b6e2e60d49a53fc9ed72d1f3607d1a10
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Wed Nov 2 15:52:59 2022 +0100

    browse: Handle snapshots whose branches target contents or directories
    
    Previously swh-web was only supporting the browsing of snapshot branches
    targeting revisions but we recently introduced new Software Heritage
    loaders producing snapshots whose branches target contents or directories
    but no revisions.
    
    So add support to browse such snapshots as previously they were flagged as
    empty when trying to display them.
    
    Related to T4669

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2120/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2120/console

Build has FAILED

Patch application report for D8816 (id=31763)

Could not rebase; Attempt merge onto d055e08d8b...

Updating d055e08d..2fdb0b16
Fast-forward
 swh/web/browse/snapshot_context.py                 | 136 +++++++---
 swh/web/browse/templates/browse-branches.html      |   9 +-
 .../templates/includes/snapshot-context.html       |   6 +-
 .../browse/templates/includes/top-navigation.html  |   6 +-
 swh/web/tests/browse/test_snapshot_context.py      |  22 +-
 swh/web/tests/browse/views/test_content.py         |   8 +-
 swh/web/tests/browse/views/test_directory.py       |  12 +-
 swh/web/tests/browse/views/test_snapshot.py        | 295 +++++++++++++++++++--
 swh/web/tests/conftest.py                          |   4 +
 swh/web/tests/utils/test_archive.py                |   7 +-
 swh/web/utils/archive.py                           |   6 +
 swh/web/utils/typing.py                            |  10 +-
 12 files changed, 426 insertions(+), 95 deletions(-)
Changes applied before test
commit 2fdb0b164b2166bb820bae0f23580ef9b842330a
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 16:43:33 2022 +0100

    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.

commit f0f3e6890a2e081c2f868a8e9a6755cd952ae227
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 14:26:10 2022 +0100

    browse: Update snapshot branches list view to display all target types
    
    Previously, the snapshot branches list view was only displaying branches
    targeting revisions but it now exists cases where branches can target
    contents or directories.
    
    So update view implementation to display all type of branches and add
    visual clues to indicate which object types they are targeting.
    
    Related to T4669

commit 8f594ec2b6e2e60d49a53fc9ed72d1f3607d1a10
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Wed Nov 2 15:52:59 2022 +0100

    browse: Handle snapshots whose branches target contents or directories
    
    Previously swh-web was only supporting the browsing of snapshot branches
    targeting revisions but we recently introduced new Software Heritage
    loaders producing snapshots whose branches target contents or directories
    but no revisions.
    
    So add support to browse such snapshots as previously they were flagged as
    empty when trying to display them.
    
    Related to T4669

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2118/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2118/console

Build has FAILED

Patch application report for D8816 (id=31763)

Could not rebase; Attempt merge onto d055e08d8b...

Updating d055e08d..2fdb0b16
Fast-forward
 swh/web/browse/snapshot_context.py                 | 136 +++++++---
 swh/web/browse/templates/browse-branches.html      |   9 +-
 .../templates/includes/snapshot-context.html       |   6 +-
 .../browse/templates/includes/top-navigation.html  |   6 +-
 swh/web/tests/browse/test_snapshot_context.py      |  22 +-
 swh/web/tests/browse/views/test_content.py         |   8 +-
 swh/web/tests/browse/views/test_directory.py       |  12 +-
 swh/web/tests/browse/views/test_snapshot.py        | 295 +++++++++++++++++++--
 swh/web/tests/conftest.py                          |   4 +
 swh/web/tests/utils/test_archive.py                |   7 +-
 swh/web/utils/archive.py                           |   6 +
 swh/web/utils/typing.py                            |  10 +-
 12 files changed, 426 insertions(+), 95 deletions(-)
Changes applied before test
commit 2fdb0b164b2166bb820bae0f23580ef9b842330a
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 16:43:33 2022 +0100

    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.

commit f0f3e6890a2e081c2f868a8e9a6755cd952ae227
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Fri Nov 4 14:26:10 2022 +0100

    browse: Update snapshot branches list view to display all target types
    
    Previously, the snapshot branches list view was only displaying branches
    targeting revisions but it now exists cases where branches can target
    contents or directories.
    
    So update view implementation to display all type of branches and add
    visual clues to indicate which object types they are targeting.
    
    Related to T4669

commit 8f594ec2b6e2e60d49a53fc9ed72d1f3607d1a10
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Wed Nov 2 15:52:59 2022 +0100

    browse: Handle snapshots whose branches target contents or directories
    
    Previously swh-web was only supporting the browsing of snapshot branches
    targeting revisions but we recently introduced new Software Heritage
    loaders producing snapshots whose branches target contents or directories
    but no revisions.
    
    So add support to browse such snapshots as previously they were flagged as
    empty when trying to display them.
    
    Related to T4669

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2119/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/2119/console