don't look up details if id is missing in backup

In case of a failure that causes the detailsID to not be
recorded in the backup, do not attempt to look up
the details from the model store.
This commit is contained in:
ryanfkeepers 2023-01-08 13:49:54 -07:00
parent 186569087c
commit 7f606eddce
2 changed files with 12 additions and 0 deletions

View File

@ -556,6 +556,12 @@ func mergeDetails(
detailsStore, detailsStore,
) )
if err != nil { if err != nil {
// if the backup has no prior details recorded, then there's nothing to merge.
if errors.Is(err, errNoDetailsID) {
logger.Ctx(ctx).Infof("backup %s contains no details ID, skipping merger", bID)
continue
}
return errors.Wrapf(err, "backup fetching base details for backup %s", bID) return errors.Wrapf(err, "backup fetching base details for backup %s", bID)
} }

View File

@ -15,6 +15,8 @@ type detailsReader interface {
ReadBackupDetails(ctx context.Context, detailsID string) (*details.Details, error) ReadBackupDetails(ctx context.Context, detailsID string) (*details.Details, error)
} }
var errNoDetailsID = errors.New("no details id in backup")
func getBackupAndDetailsFromID( func getBackupAndDetailsFromID(
ctx context.Context, ctx context.Context,
backupID model.StableID, backupID model.StableID,
@ -26,6 +28,10 @@ func getBackupAndDetailsFromID(
return nil, nil, errors.Wrap(err, "getting backup details ID") return nil, nil, errors.Wrap(err, "getting backup details ID")
} }
if len(dID) == 0 {
return nil, nil, errNoDetailsID
}
deets, err := detailsStore.ReadBackupDetails(ctx, dID) deets, err := detailsStore.ReadBackupDetails(ctx, dID)
if err != nil { if err != nil {
return nil, nil, errors.Wrap(err, "getting backup details data") return nil, nil, errors.Wrap(err, "getting backup details data")