Draft: Handle snapshot missing root directory
fixes #4824
instead of using an assert to please mypy we raise a NotFoundExc
when a snapshot is missing a root directory to avoid an unhandled exception in sentry (which happens only in staging due to a missing revision in staging storage)
Merge request reports
Activity
assigned to @rboyer
mentioned in issue #4824
Jenkins job DWAPPS/gitlab-builds #1408 succeeded in 10 min.
See Console Output, Blue Ocean and Coverage Report for more details.I think we should rather check if the object targeted by a branch (revision, release, directory or content) exists in the archive directly in the
get_snapshot_context
function and raise aNotFoundExc
with a detailed error message like:Revision <rev_id> targeted by branch <branch_name> from snapshot <snapshot_id> cannot be found in the archive
.Currently there is already some of those checks performed by calls to
archive.lookup_revision
orarchive.lookup_release
but some are missing and the 404 error message only saysRevision <rev_id> cannot be found
. Some refactoring could be made in theget_snapshot_context
to catch theNotFoundExc
exceptions and reraise them with better error messages including snapshot info.I think I disagree with this: there is no reason for a function called "get_snapshot_context" to raise a NotFoundError in this case. This function does a lot of things, no reason to make it fail in this particular case IMHO. It's the responsibility of the caller to do the right thing.
So I'd rather go for this proposal...
So what do you think about this @anlambert ?
added 22 commits
-
a4249a6c...2d49d142 - 21 commits from branch
swh/devel:master
- cf3e6554 - Handle snapshot missing root directory in staging
-
a4249a6c...2d49d142 - 21 commits from branch
Jenkins job DWAPPS/gitlab-builds #1455 succeeded in 9 min 7 sec.
See Console Output, Blue Ocean and Coverage Report for more details.added 11 commits
-
cf3e6554...ade2b0a1 - 10 commits from branch
swh/devel:master
- 59e768c1 - Handle snapshot missing root directory in staging
-
cf3e6554...ade2b0a1 - 10 commits from branch
Jenkins job DWAPPS/gitlab-builds #1511 failed in 8 min 50 sec.
See Console Output, Blue Ocean and Coverage Report for more details.Jenkins job DWAPPS/gitlab-builds #1515 failed in 8 min 52 sec.
See Console Output, Blue Ocean and Coverage Report for more details.