HomeSoftware Heritage

package.loader: Check for snapshot id prior to reifying model object

Description

package.loader: Check for snapshot id prior to reifying model object

This is an issue mostly encountered on staging. But technically, the error
could happen in production as snapshot_get_all_branches could return None as
well (which is currently ignored). If that happens though, Snapshot.from_dict
raises.

Most proeminent in staging, because we can mount partial dump from production.
Thus not everything exists. Typically, recently we mounted a partial dump of
origins/origin-visits only. This means origin visits will target inexisting
snapshots [1]

Thix fix ensures we can use staging nonetheless. This also improves the current
implementation path so win.

Related to T2428

[1] https://sentry.softwareheritage.org/share/issue/4eb69ea2cc314c4ab811809ff60c358f/