fix(migration): do not crash when relating a task to itself

Resolves https://community.vikunja.io/t/vikunja-import-error-tried-to-relate-a-task-with-itself/1105
This commit is contained in:
kolaente 2025-03-02 13:24:55 +01:00
parent c6cade3aeb
commit 2ead48c1e9
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 7 additions and 0 deletions

View File

@ -352,6 +352,13 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas
if ttt, exists := tasksByOldID[rt.ID]; exists {
taskRel.OtherTaskID = ttt.ID
}
// Add this check to prevent self-relations
if taskRel.TaskID == taskRel.OtherTaskID {
log.Debugf("[creating structure] Skipping invalid self-relation for task %d", taskRel.TaskID)
continue
}
err = taskRel.Create(s, user)
if err != nil && !models.IsErrRelationAlreadyExists(err) {
return