From 069685f2a7423fc579f0a897ae6c7ef448b69b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Lapeyre?= Date: Thu, 28 May 2026 08:14:52 +0200 Subject: [PATCH] fix(caldav): return 404 when trying to access a project that cannot exist with CalDAV (#2796) --- pkg/routes/caldav/handler.go | 3 ++- pkg/webtests/caldav_test.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/routes/caldav/handler.go b/pkg/routes/caldav/handler.go index 395313a5e..7338b3961 100644 --- a/pkg/routes/caldav/handler.go +++ b/pkg/routes/caldav/handler.go @@ -185,7 +185,8 @@ func getProjectFromParam(c *echo.Context) (project *models.ProjectWithTasksAndBu intParam, err := strconv.ParseInt(param, 10, 64) if err != nil { - return nil, err + // The project ID given is not an integer, it cannot exist + return nil, models.ErrProjectDoesNotExist{} } if intParam == models.FavoritesPseudoProjectID { diff --git a/pkg/webtests/caldav_test.go b/pkg/webtests/caldav_test.go index 900772d0c..2cae0128e 100644 --- a/pkg/webtests/caldav_test.go +++ b/pkg/webtests/caldav_test.go @@ -44,6 +44,12 @@ func TestCaldav(t *testing.T) { assert.Contains(t, rec.Body.String(), "END:VTODO") assert.Contains(t, rec.Body.String(), "END:VCALENDAR") }) + t.Run("Returns 404 for non-integer project param", func(t *testing.T) { + e, _ := setupTestEnv() + rec, err := newCaldavTestRequestWithUser(t, e, http.MethodGet, caldav.ProjectHandler, &testuser15, ``, nil, map[string]string{"project": "E6948AA3-86CC-40A1-874D-3B0A02FAA781"}) + require.NoError(t, err) + assert.Equal(t, http.StatusNotFound, rec.Result().StatusCode) + }) t.Run("Import VTODO", func(t *testing.T) { const vtodo = `BEGIN:VCALENDAR VERSION:2.0