From d758bdc5e2d63d75811d39f1c65c3bd50117c807 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 5 Jun 2023 18:12:12 +0200 Subject: [PATCH] fix(projects): don't try to share for nonexisting namespace --- pkg/migration/20221228112131.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/migration/20221228112131.go b/pkg/migration/20221228112131.go index 9b9d59c08..8c2175d49 100644 --- a/pkg/migration/20221228112131.go +++ b/pkg/migration/20221228112131.go @@ -17,6 +17,7 @@ package migration import ( + "code.vikunja.io/api/pkg/log" "time" "src.techknowlogick.com/xormigrate" @@ -245,6 +246,11 @@ func setTeamNamespacesShare(tx *xorm.Engine, namespacesToProjects map[int64]*pro } for _, tn := range teamNamespaces { + if _, exists := namespacesToProjects[tn.NamespaceID]; !exists { + log.Warningf("Namespace %d does not exist but is shared with team %d - this is probably caused by an old share which was not properly deleted.", tn.NamespaceID, tn.TeamID) + continue + } + _, err = tx.Insert(&teamProject20221228112131{ TeamID: tn.TeamID, Right: tn.Right, @@ -268,6 +274,11 @@ func setUserNamespacesShare(tx *xorm.Engine, namespacesToProjects map[int64]*pro } for _, un := range userNamespace { + if _, exists := namespacesToProjects[un.NamespaceID]; !exists { + log.Warningf("Namespace %d does not exist but is shared with user %d - this is probably caused by an old share which was not properly deleted.", un.NamespaceID, un.UserID) + continue + } + _, err = tx.Insert(&projectUser20221228112131{ UserID: un.UserID, Right: un.Right,