Skip to content

Commit

Permalink
failed to updated definitions: forbidden empty slice
Browse files Browse the repository at this point in the history
  • Loading branch information
milosgagovic committed Oct 23, 2023
1 parent b115308 commit 691b1ae
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ func CreateRedirectsHandler(repo *redirectrepository.RedirectsDefinitionReposito
l.Info("calling consolidate automatic redirects")
consolidatedDefs, deletedDefs := redirectdefinitionutils.ConsolidateRedirectDefinitions(l, *oldDefinitions, newDefinitions)

updateErr := repo.UpsertMany(ctx, &consolidatedDefs)
if updateErr != nil {
l.Error("failed to updated definitions", zap.Error(updateErr))
return updateErr
if len(consolidatedDefs) > 0 {
updateErr := repo.UpsertMany(ctx, &consolidatedDefs)
if updateErr != nil {
l.Error("failed to updated definitions", zap.Error(updateErr))
return updateErr
}
}

deleteErr := repo.DeleteMany(ctx, deletedDefs)
if deleteErr != nil {
l.Error("failed to delete definitions", zap.Error(deleteErr))
return deleteErr
if len(deletedDefs) > 0 {
deleteErr := repo.DeleteMany(ctx, deletedDefs)
if deleteErr != nil {
l.Error("failed to delete definitions", zap.Error(deleteErr))
return deleteErr
}
}

l.Info("successfully finished create automatic redirects")
return nil
}
Expand Down

0 comments on commit 691b1ae

Please sign in to comment.