nextcloud / server

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

[Bug]: webdav: Exception: DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta) #41606

Closed iheinrich closed 2 months ago

iheinrich commented 10 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

Importing .ics via webdav fails for calendar entries with "India Standard Time" timezone: "Internal Server Error" (code 500) is reported back to the webdav client and "Error Exception: DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta)" is logged. Webdav client used is vdirsyncer.

Manually importing same .ics file via "Calendar settings -> Import calendar" works fine.

Example .ics file, exported from MS Outlook: example_ics.txt

Steps to reproduce

  1. Import example_ics.txt via WebDav

Expected behavior

ICS with timezone "India Standard Time" can be imported via WebDav.

Installation method

Community Manual installation with Archive

Nextcloud Server version

27

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database engine version

PostgreSQL

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

Upgraded to a MAJOR version (ex. 22 to 23)

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

{
    "system": {
        "version": "27.1.3.2",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "https:\/\/***REMOVED PUBLIC HOST***\/nextcloud",
        "dbtype": "pgsql",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "nc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "ldapIgnoreNamingRules": false,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "overwritehost": "***REMOVED PUBLIC HOST***",
        "overwriteprotocol": "https",
        "overwritewebroot": "\/nextcloud",
        "theme": "",
        "maintenance": false,
        "forcessl": true,
        "loglevel": 2,
        "default_language": "de",
        "updatechecker": false,
        "logtimezone": "Europe\/Berlin",
        "cron_log": true,
        "log_rotate_size": 41451520,
        "appcodechecker": false,
        "trashbin_retention_obligation": "auto",
        "htaccess.RewriteBase": "\/nextcloud",
        "singleuser": false,
        "check_for_working_wellknown_setup": true,
        "memcache.local": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": "true",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0,
            "dbindex": 4
        },
        "knowledgebaseenabled": false,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "dbport": "5432",
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_sendmailmode": "smtp",
        "mail_smtpport": "25",
        "installed": true,
        "ldapUserCleanupInterval": 0,
        "activity_expire_days": 31,
        "default_phone_region": "DE",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 2.19.0
  - calendar: 4.5.3
  - cloud_federation_api: 1.10.0
  - contacts: 5.4.2
  - dashboard: 7.7.0
  - dav: 1.27.0
  - federatedfilesharing: 1.17.0
  - files: 1.22.0
  - files_pdfviewer: 2.8.0
  - files_reminders: 1.0.0
  - files_rightclick: 1.6.0
  - files_sharing: 1.19.0
  - files_trashbin: 1.17.0
  - files_versions: 1.20.0
  - groupfolders: 15.3.1
  - logreader: 2.12.0
  - lookup_server_connector: 1.15.0
  - notes: 4.8.1
  - notifications: 2.15.0
  - oauth2: 1.15.1
  - password_policy: 1.17.0
  - photos: 2.3.0
  - privacy: 1.11.0
  - provisioning_api: 1.17.0
  - related_resources: 1.2.0
  - serverinfo: 1.17.0
  - settings: 1.9.0
  - sharebymail: 1.17.0
  - text: 3.8.0
  - theming: 2.2.0
  - twofactor_backupcodes: 1.16.0
  - updatenotification: 1.17.0
  - user_ldap: 1.17.0
  - user_status: 1.7.0
  - viewer: 2.1.0
  - weather_status: 1.7.0
  - workflowengine: 2.9.0
Disabled:
  - admin_audit: 1.17.0
  - bruteforcesettings: 2.7.0 (installed 2.2.0)
  - circles: 27.0.1 (installed 23.0.0)
  - comments: 1.17.0 (installed 1.13.0)
  - contactsinteraction: 1.8.0 (installed 1.4.0)
  - encryption: 2.15.0
  - federation: 1.17.0 (installed 1.7.0)
  - files_external: 1.19.0
  - firstrunwizard: 2.16.0 (installed 2.6.0)
  - nextcloud_announcements: 1.16.0 (installed 1.12.0)
  - recommendations: 1.6.0 (installed 0.5.0)
  - support: 1.10.0 (installed 1.0.1)
  - survey_client: 1.15.0 (installed 1.5.0)
  - suspicious_login: 5.0.0
  - systemtags: 1.17.0 (installed 1.7.0)
  - twofactor_totp: 9.0.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{
    "reqId": "ZVn5ocuM_Ogaip1nWMoqYgAAAAM",
    "level": 3,
    "time": "2023-11-19T13:03:46+01:00",
    "remoteAddr": "<redacted>",
    "user": "test",
    "app": "webdav",
    "method": "PUT",
    "url": "/nextcloud/remote.php/dav/calendars/test/personal/040000008200E00074C5B7101A82E00800000000F0027764A811DA01000000000000000010000000935D8FF043328A4B83196FDABE75A2F3.ics",
    "message": "DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta)",
    "userAgent": "vdirsyncer/0.19.2",
    "version": "27.1.3.2",
    "exception": {
        "Exception": "Exception",
        "Message": "DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta)",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/TimezoneGuesser/FindFromTimezoneMap.php",
                "line": 25,
                "function": "__construct",
                "class": "DateTimeZone",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/TimeZoneUtil.php",
                "line": 81,
                "function": "find",
                "class": "Sabre\\VObject\\TimezoneGuesser\\FindFromTimezoneMap",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/TimeZoneUtil.php",
                "line": 131,
                "function": "findTimeZone",
                "class": "Sabre\\VObject\\TimeZoneUtil",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/Property/ICalendar/DateTime.php",
                "line": 162,
                "function": "getTimeZone",
                "class": "Sabre\\VObject\\TimeZoneUtil",
                "type": "::"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/Property/ICalendar/DateTime.php",
                "line": 136,
                "function": "getDateTimes",
                "class": "Sabre\\VObject\\Property\\ICalendar\\DateTime",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/ITip/Broker.php",
                "line": 890,
                "function": "getDateTime",
                "class": "Sabre\\VObject\\Property\\ICalendar\\DateTime",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/vobject/lib/ITip/Broker.php",
                "line": 195,
                "function": "parseEventInfo",
                "class": "Sabre\\VObject\\ITip\\Broker",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
                "line": 616,
                "function": "parseEvent",
                "class": "Sabre\\VObject\\ITip\\Broker",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
                "line": 337,
                "function": "processICalendarChange",
                "class": "Sabre\\CalDAV\\Schedule\\Plugin",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/CalDAV/Schedule/Plugin.php",
                "line": 164,
                "function": "calendarObjectChange",
                "class": "Sabre\\CalDAV\\Schedule\\Plugin",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
                "line": 89,
                "function": "calendarObjectChange",
                "class": "OCA\\DAV\\CalDAV\\Schedule\\Plugin",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
                "line": 889,
                "function": "emit",
                "class": "Sabre\\DAV\\Server",
                "type": "->"
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
                "line": 760,
                "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": 365,
                "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/vobject/lib/TimezoneGuesser/FindFromTimezoneMap.php",
        "Line": 25,
        "message": "DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta)",
        "exception": [],
        "CustomMessage": "DateTimeZone::__construct(): Unknown or bad timezone (Asia/Calcutta)"
    },
    "id": "6559fe5b09e58"
}

Additional info

No response

joshtrichards commented 10 months ago

Can you provide the output of these command from your server?

date -u; TZ=Asia/Calcutta date php -r 'echo join("\n", DateTimeZone::listIdentifiers( DateTimeZone::ALL_WITH_BC ));' | grep Calcutta

What version of Debian/Ubuntu?

iheinrich commented 10 months ago

Debian version is unstable ("trixie/sid") with all packages updated, the installed version of tzdata is 2023c-10. Installing tzdata-legacy FIXES the issue. So anyone on Debian testing or unstable can install tzdata-legacy to fix this.

With tzdata 2023c-10 and without tzdata-legacy date -u; TZ=Asia/Calcutta date prints:

Di 21. Nov 22:06:43 UTC 2023
Di 21. Nov 22:06:43 Asia 2023

But date -u; TZ=Asia/Kolkata date always prints:

Di 21. Nov 22:06:43 UTC 2023
Mi 22. Nov 03:36:43 IST 2023

Also without tzdata-legacy php -r 'echo join("\n", DateTimeZone::listIdentifiers( DateTimeZone::ALL_WITH_BC ));' | grep Calcutta has no output But php -r 'echo join("\n", DateTimeZone::listIdentifiers( DateTimeZone::ALL_WITH_BC ));' | grep Kolkata always prints:

Asia/Kolkata

Thanks for pointing me in the right direction!

joshtrichards commented 10 months ago

Related: #39767

Sounds like it may be time to add a note about tzdata-legacy (or its equivalent on other distros) being a requirement for broadly compatible timezones.

SebastianKrupinski commented 2 months ago

Tested on version 27 and Debian 12.

Provided test event imported correctly.