diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py index 18348c9569a948097b8fb18ec3fefcbd42648376..0995c4caf1ab18504a2d5cc298502610e283b5a2 100644 --- a/swh/web/browse/views/content.py +++ b/swh/web/browse/views/content.py @@ -238,9 +238,10 @@ def _get_content_from_request(request: HttpRequest) -> Dict[str, Any]: browse_context="content", visit_type=request.GET.get("visit_type"), ) - root_directory = snapshot_context["root_directory"] - assert root_directory is not None # to keep mypy happy - return archive.lookup_directory_with_path(root_directory, path) + if root_directory := snapshot_context["root_directory"]: + return archive.lookup_directory_with_path(root_directory, path) + # this should only happen in staging due to a partial storage + raise NotFoundExc(f"Missing root directory for {snapshot}") @browse_route(