nextcloud / nextcloud/calendar
Calendar export: `Argument #3 ($subject) must be of type array|string, null given`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 332
- Avg merge
- 16h 13m
- Merged PRs (30d)
- 137
Description
Steps to reproduce
- click on the calendar edit button (pencil) on the left
- click on
Export
or
- just try to download the calendar via the URL using auth
![NOTE] This error does not happen for all calendars
Expected behavior
Nextcloud should export the calendar and the download should start
Actual behavior
HTTP error 500 (see log below)
Calendar app version
4.7.16
CalDAV-clients used
Web UI
Browser
No response
Client operating system
Debian
Server operating system
Debian
Web server
Apache
Database engine version
PostgreSQL
PHP engine version
None
Nextcloud version
29.0.14
Updated from an older installed version or fresh install
Updated from an older version
List of activated apps
Nextcloud configuration
Web server error log
Log file
{"reqId":"x","level":3,"time":"x","remoteAddr":"x","user":"x",
"app":"webdav","method":"GET","url":"/remote.php/dav/calendars/x/n/?export",
"message":"str_replace(): Argument #3 ($subject) must be of type array|string, null given",
"userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0",
"version":"29.0.14.1",
"exception":{"Exception":"TypeError","Message":"str_replace(): Argument #cal/}calendar-color":"#9B9B9B",
"0":"And 1 more entries, set log level to debug to see all entries"},
{"__class__":"Sabre3 ($subject) must be of type array|string, null given","Code":0,
"Trace":[{"file":"/var/www/html/3rdparty/sabre/dav/lib/CalDAV/Plugin.php","line":420,
"function":"str_replace","args":["\r","",null]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/PropFind.php","line":95,
"function":"Sabre\\CalDAV\\{closure}","class":"Sabre\\CalDAV\\Plugin",
"type":"->","args":["*** sensitive parameters replaced ***"]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
"line":405,"function":"handle","class":"Sabre\\DAV\\PropFind",
"type":"->","args":["{urn:ietf:params:xml:ns:caldav}calendar-data",
{"__class__":"Closure"}]},
{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,
"function":"propFind","class":"Sabre\\CalDAV\\Plugin","type":"->",
"args":[{"__class__":"Sabre\\DAV\\PropFind"},
{"__class__":"OCA\\DAV\\CalDAV\\CalendarObject"}]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":1052,
"function":"emit","class":"Sabre\\DAV\\Server","type":"->",
"args":["propFind",[{"__class__":"Sabre\\DAV\\PropFind"},
{"__class__":"OCA\\DAV\\CalDAV\\CalendarObject"}]]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
"line":984,"function":"getPropertiesByNode",
"class":"Sabre\\DAV\\Server","type":"->",
"args":[{"__class__":"Sabre\\DAV\\PropFind"},
{"__class__":"OCA\\DAV\\CalDAV\\CalendarObject"}]},
{"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->",
"args":["calendars/x/n",["{urn:ietf:params:xml:ns:caldav}calendar-data"],1]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":941,
"function":"iterator_to_array","args":[{"__class__":"Generator"}]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/CalDAV/ICSExportPlugin.php",
"line":214,"function":"getPropertiesForPath","class":"Sabre\\DAV\\Server",
"type":"->","args":["calendars/x/n",["{urn:ietf:params:xml:ns:caldav}calendar-data"],1]},
{"file":"/var/www/html/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php","line":61,
"function":"generateResponse","class":"Sabre\\CalDAV\\ICSExportPlugin","type":"->",
"args":["calendars/x/n",null,null,false,false,"text/calendar",
{"{DAV:}resourcetype":{"__class__":"Sabre\\DAV\\Xml\\Property\\ResourceType"},
"{DAV:}displayname":"N","{http://sabredav.org/ns}sync-token":399,
"{DAV:}sync-token":"http://sabre.io/ns/sync/399",
"{http://apple.com/ns/ical/}calendar-color":"#9B9B9B","0":"And 1 more entries, set log level to debug to see all entries"},
{"__class__":"Sabre\\HTTP\\Response"}]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/CalDAV/ICSExportPlugin.php",
"line":155,"function":"generateResponse","class":"OCA\\DAV\\CalDAV\\ICSExportPlugin\\ICSExportPlugin",
"type":"->","args":["calendars/x/n",null,null,false,false,"text/calendar",
{"{DAV:}resourcetype":{"__class__":"Sabre\\DAV\\Xml\\Property\\ResourceType"},
"{DAV:}displayname":"N",
"{http://sabredav.org/ns}sync-token":399,
"{DAV:}sync-token":"http://sabre.io/ns/sync/399",
"{http://apple.com/ns/i\\HTTP\\Response"}]},
{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
"line":89,"function":"httpGet","class":"Sabre\\CalDAV\\ICSExportPlugin",
"type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},
{"__class__":"Sabre\\HTTP\\Response"}]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
"line":472,"function":"emit","class":"Sabre\\DAV\\Server",
"type":"->","args":["method:GET",[{"__class__":"Sabre\\HTTP\\Request"},
{"__class__":"Sabre\\HTTP\\Response"}]]},
{"file":"/var/www/html/apps/dav/lib/Connector/Sabre/Server.php",
"line":67,"function":"invokeMethod","class":"Sabre\\DAV\\Server",
"type":"->","args":[{"__class__":"Sabre\\HTTP\\Request"},
{"__class__":"Sabre\\HTTP\\Response"}]},
{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,
"function":"start","class":"OCA\\DAV\\Connector\\Sabre\\Server","type":"->","args":[]},
{"file":"/var/www/html/apps/dav/lib/Server.php","line":396,"function":"exec","class":"Sabre\\DAV\\Server",
"type":"->","args":[]},
"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server",
"type":"->","args":[]},{"file":"/var/www/html/remote.php",
"line":172,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],
"function":"require_once"}],
"File":"/var/www/html/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
"Line":420,
"message":"str_replace(): Argument #3 ($subject) must be of type array|string, null given",
"exception":{},
"CustomMessage":"str_replace(): Argument #3 ($subject) must be of type array|string, null given"}}
Browser log
Additional info
I'm using a Docker environment for Nextcloud, Postgres and Collabora.
I provided a redacted section of the log file containing the error.
This is a mitigation through which I can download the exported calendars, although I haven't checked if entries are missing or if the export is accurate:
@/var/www/3rdparty/sabre/dav/lib/CalDAV/Plugin.php LINE 411
- return str_replace("\r", '', $val);
+ if (is_null($val)) {
+ return $val;
+ }
+ else {
+ return str_replace("\r", '', $val);
+ }
Before experiencing this error I migrated from PostgreSQL 13 on the host to PostgreSQL 17 on a Docker container. I did a database dump and imported it in the container. Apparently no errors were reported, however this might be a factor to consider.
I noticed this problem when one of my script reported a failure while exporting the calendars.
I'm not sure if the database migration caused the error, or if it's something else since my Systemd logs don't go far back.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the authenticated export request at /remote.php/dav/calendars/.../?export and inspect 3rdparty/sabre/dav/lib/CalDAV/Plugin.php around line 420 and apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php. Compare calendars that export successfully with the affected calendar and determine why calendar-data reaches str_replace() as null. Done means affected calendars export successfully without losing entries and the behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, postgresql
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100