From 7f606eddce10f64676b62d4c3eef62cc42adff74 Mon Sep 17 00:00:00 2001 From: ryanfkeepers Date: Sun, 8 Jan 2023 13:49:54 -0700 Subject: [PATCH] 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. --- src/internal/operations/backup.go | 6 ++++++ src/internal/operations/common.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 8ba5869f3..b12a2e773 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -556,6 +556,12 @@ func mergeDetails( detailsStore, ) 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) } diff --git a/src/internal/operations/common.go b/src/internal/operations/common.go index addbeb5ac..763d92629 100644 --- a/src/internal/operations/common.go +++ b/src/internal/operations/common.go @@ -15,6 +15,8 @@ type detailsReader interface { ReadBackupDetails(ctx context.Context, detailsID string) (*details.Details, error) } +var errNoDetailsID = errors.New("no details id in backup") + func getBackupAndDetailsFromID( ctx context.Context, backupID model.StableID, @@ -26,6 +28,10 @@ func getBackupAndDetailsFromID( return nil, nil, errors.Wrap(err, "getting backup details ID") } + if len(dID) == 0 { + return nil, nil, errNoDetailsID + } + deets, err := detailsStore.ReadBackupDetails(ctx, dID) if err != nil { return nil, nil, errors.Wrap(err, "getting backup details data")