From 1d2090a4aaa8d5c0beb6c280b674bcf379e1d13a Mon Sep 17 00:00:00 2001 From: Renaud Boyer <renaud.boyer@sofwareheritage.org> Date: Tue, 7 Jan 2025 13:53:53 +0100 Subject: [PATCH] Handle snapshot missing root directory in staging --- swh/web/browse/views/content.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py index 18348c956..0995c4caf 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( -- GitLab