nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.27k stars 3.96k forks source link

[Bug]: CalDAV error when trying to add a calendar event [iCalendar objects must at least have a component of type VTODO] #45503

Closed lord0gnome closed 1 day ago

lord0gnome commented 2 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

I have installed both the Tasks app, and the Calendar app, versions of both are: Tasks: 0.15.0 Calendar 4.7.4

I cannot create new events from the calendar app. (From tasks app it works just fine)

Steps to reproduce

  1. Fairly fresh Nextcloud 29.0.0 installation
  2. Install tasks app, create many tasks with due dates and start dates
  3. Install calendar app, try to create ANY event. (I can't create any at all)

Expected behavior

I would expect it not to throw an error when I try to create a new calendar event.

Installation method

Community Manual installation with Archive

Nextcloud Server version

29

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",     
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",   
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***",
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "enable_previews": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\Movie",
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\MP4",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\PDF",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\Image"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "maintenance_window_start": 1,
        "filelocking.enabled": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "default_phone_region": "***REMOVED SENSITIVE VALUE***",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "dbtype": "mysql",
        "loglevel": 2,
        "cron_log": true,
        "version": "29.0.0.19",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "app_install_overwrite": [
            "tasks",
            "dashboardcharts"
        ],
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false
    }
}

List of activated Apps

Enabled:
  - activity: 2.21.1
  - calendar: 4.7.4
  - circles: 29.0.0-dev
  - cloud_federation_api: 1.12.0
  - comments: 1.19.0
  - contactsinteraction: 1.10.0
  - cospend: 1.6.1
  - dashboard: 7.9.0
  - dav: 1.30.1
  - deck: 1.13.0
  - federatedfilesharing: 1.19.0
  - federation: 1.19.0
  - files: 2.1.0
  - files_downloadlimit: 2.0.0
  - files_pdfviewer: 2.10.0
  - files_reminders: 1.2.0
  - files_sharing: 1.21.0
  - files_trashbin: 1.19.0
  - files_versions: 1.22.0
  - firstrunwizard: 2.18.0
  - logreader: 2.14.0
  - lookup_server_connector: 1.17.0
  - memories: 7.3.1
  - nextcloud_announcements: 1.18.0
  - notes: 4.10.0
  - notifications: 2.17.0
  - oauth2: 1.17.0
  - password_policy: 1.19.0
  - photos: 2.5.0
  - previewgenerator: 5.5.0
  - privacy: 1.13.0
  - provisioning_api: 1.19.0
  - recommendations: 2.1.0
  - related_resources: 1.4.0
  - serverinfo: 1.19.0
  - settings: 1.12.0
  - sharebymail: 1.19.0
  - support: 1.12.0
  - survey_client: 1.17.0
  - systemtags: 1.19.0
  - tasks: 0.16.0
  - text: 3.10.0
  - theming: 2.4.0
  - twofactor_backupcodes: 1.18.0
  - updatenotification: 1.19.1
  - user_status: 1.9.0
  - viewer: 2.3.0
  - weather_status: 1.9.0
  - workflowengine: 2.11.0
Disabled:
  - admin_audit: 1.19.0
  - bruteforcesettings: 2.9.0
  - encryption: 2.17.0
  - files_external: 1.21.0
  - suspicious_login: 7.0.0
  - twofactor_totp: 11.0.0-dev
  - user_ldap: 1.20.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"Z85VE58sQfvuN9KY5EGg","level":3,"time":"2024-05-25T07:08:15+00:00","remoteAddr":"78.198.62.54","user":"USERID","app":"webdav","method":"PUT","url":"/remote.php/dav/calendars/USERID/tasks/CE082C3B-F9BC-4337-BA48-A18128959648.ics","message":"iCalendar objects must at least have a component of type VTODO","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36","version":"29.0.0.19","exception":{"Exception":"Sabre\\CalDAV\\Exception\\InvalidComponentType","Message":"iCalendar objects must at least have a component of type VTODO","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php","line":766,"function":"validateICalendar","class":"Sabre\\CalDAV\\Plugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"beforeCreateFile","class":"Sabre\\CalDAV\\Plugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1094,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":504,"function":"createFile","class":"Sabre\\DAV\\Server","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPut","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":374,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":172,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php","Line":840,"message":"iCalendar objects must at least have a component of type VTODO","exception":[],"CustomMessage":"iCalendar objects must at least have a component of type VTODO"},"id":"6651923fbc682"}

Additional info

PUT https://mycloud.tld/remote.php/dav/calendars/UID/tasks/8ABB8456-7E73-4FDC-A278-200DF6C9A971.ics 403 (Forbidden)

kesselb commented 2 months ago

The put request tries to create an event in the tasks calendar.

You should also have a personal calendar. Does it work if you create an event there?

Etelop commented 1 month ago

The put request tries to create an event in the tasks calendar.

You should also have a personal calendar. Does it work if you create an event there?

Do you mean that you can't create in one Calendar file a Task event at same time that a Calendar event? You can't have together Tasks and Events into de same Calendar?

HaTiIn commented 1 month ago

I have the same problem

lord0gnome commented 1 month ago

You are both correct. I was trying to add an event in the tasks calendar. It works just fine when I use a calendar created inside of the calendar app. Thank you. :)

Etelop commented 1 month ago

You can also do it by adding in MySQL data base on the table "oc_calendars" inside the value of "components" the instruction VTODO or VEVENT depending on which is missing.

lord0gnome commented 1 month ago

I've re-opened this because even on events created within the calendars app, I am getting the same error in my logs. I have not yet identified the cause.

mrxorao commented 1 month ago

I'm having the same problem.

Edit: I've solved it, I went to the calendar settings and changed the default calendar to one created within the app!

jansppenrade2 commented 1 month ago

The workarounds mentioned are not working for me. Multiple users having the same problem. Calenders not syncing anymore and creating new calender events in the calendar app results in errors...

Currenly on Nextcloud 29.01.

What I tried so far:

miaulalala commented 1 month ago

Does anyone have a failing ics for me please? You can extract it from the network tab in your browser console

Erroring code is here: https://github.com/sabre-io/dav/blob/master/lib/CalDAV/Plugin.php#L819C1-L841C10

jwillikers commented 1 month ago

I'm having the same problem.

Edit: I've solved it, I went to the calendar settings and changed the default calendar to one created within the app!

Thanks, this worked for me! Couldn't figure out how to set the default, so I updated the database entry for my preferred calendar to be -1 instead of 0 to default to it.

jansppenrade2 commented 1 month ago

In my case, an additional error appeared in the logs when I accidentally tried to change the calendar order:

{
    "reqId": "DxCPM2xVnT0byqkUixKi",
    "level": 3,
    "time": "2024-06-04T13:57:22+00:00",
    "remoteAddr": "189.225.36.0",
    "user": "admin",
    "app": "webdav",
    "method": "PROPPATCH",
    "url": "/remote.php/dav/calendars/admin/aufgaben/",
    "message": "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'field list'",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
    "version": "29.0.1.1",
    "exception": {
        "Exception": "OC\\DB\\Exceptions\\DbalException",
        "Message": "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'field list'",
        "Code": 1054,
        "Trace": [
            {
                <...>
                "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
                "Line": 130
            }
        ]
    },
    "message": "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'field list'",
    "exception": [],
    "CustomMessage": "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in 'field list'"
},
"id": "665f1d4bdfdec"

When I created the created_at column in the oc_calendarchanges table, I was immediately able to change the calendar order and create new appointments in the calendar app. Additionally, CalDAV sync is now working properly again.

SQL command to create the missing column:

ALTER TABLE `oc_calendarchanges` ADD `created_at` INT(11) NULL DEFAULT '0' ;
kesselb commented 1 month ago

The migration for oc_calendarchanges.created_at was part of https://github.com/nextcloud/server/pull/44075. Is oc_addressbookchanges.created_at also missing and do you see "1025Date20240308063933" in oc_miagrations?

jansppenrade2 commented 1 month ago

The migration for oc_calendarchanges.created_at was part of #44075. Is oc_addressbookchanges.created_at also missing and do you see "1025Date20240308063933" in oc_miagrations?

Thank you @kesselb. Indeed oc_addressbookchanges.created_at was also missing and I added it manually now. There is no entry 1025Date20240308063933 listed in oc_migrations.

st3iny commented 1 month ago

I worked a bit on this issue and there are now 3 fixes/improvements to prevent this situation in the future:

  1. The default calendar picker won't let users select task lists.
  2. The selected default calendar is not used in the editor's calendar picker.
  3. The backend will now reject unsuitable calendars and won't use them for scheduling purpooses.