From 62799c129b96173993827d74d09be2ebf10dbf67 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 13 Dec 2025 15:30:22 +0100 Subject: [PATCH] fix(caldav): do not assume the first element is the VTODO component Cherry-Picked from https://github.com/go-vikunja/vikunja/pull/748#issuecomment-3649092134 --- pkg/caldav/parsing.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/caldav/parsing.go b/pkg/caldav/parsing.go index 113b80774..cf4966cbd 100644 --- a/pkg/caldav/parsing.go +++ b/pkg/caldav/parsing.go @@ -274,8 +274,14 @@ func ParseTaskFromVTODO(content string) (vTask *models.Task, err error) { if len(parsed.Components) == 0 { return nil, errors.New("VTODO element does seem not contain any components") } - vTodo, ok := parsed.Components[0].(*ics.VTodo) - if !ok { + var vTodo *ics.VTodo + for _, comp := range parsed.Components { + if todo, ok := comp.(*ics.VTodo); ok { + vTodo = todo + break + } + } + if vTodo == nil { return nil, errors.New("VTODO element not found") } // We put the vTodo details in a map to be able to handle them more easily