fix(caldav): return 404 when trying to access a project that cannot exist with CalDAV (#2796)

This commit is contained in:
Rémi Lapeyre 2026-05-28 08:14:52 +02:00 committed by GitHub
parent 50bece8cdb
commit 069685f2a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -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 {

View File

@ -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