{"record":{"id":"d6a56809c3c5f97f","repo":"nextcloud/server","slug":"calendar-calendarid-does-not-support-exporting","errorCode":null,"errorMessage":"Calendar <$calendarId> does not support exporting","messagePattern":"Calendar <\\$calendarId> does not support exporting","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"warning","filePath":"apps/dav/lib/Command/ExportCalendar.php","lineNumber":70,"sourceCode":"\n\t#[\\Override]\n\tprotected function execute(InputInterface $input, OutputInterface $output): int {\n\t\t$userId = $input->getArgument('uid');\n\t\t$calendarId = $input->getArgument('uri');\n\t\t$format = $input->getOption('format');\n\t\t$location = $input->getOption('location');\n\n\t\tif (!$this->userManager->userExists($userId)) {\n\t\t\tthrow new InvalidArgumentException(\"User <$userId> not found.\");\n\t\t}\n\t\t// retrieve calendar and evaluate if export is supported\n\t\t$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId, [$calendarId]);\n\t\tif ($calendars === []) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> not found.\");\n\t\t}\n\t\t$calendar = $calendars[0];\n\t\tif (!$calendar instanceof ICalendarExport) {\n\t\t\tthrow new InvalidArgumentException(\"Calendar <$calendarId> does not support exporting\");\n\t\t}\n\t\t// construct options object\n\t\t$options = new CalendarExportOptions();\n\t\t// evaluate if provided format is supported\n\t\tif (!in_array($format, ExportService::FORMATS, true)) {\n\t\t\tthrow new InvalidArgumentException(\"Format <$format> is not valid.\");\n\t\t}\n\t\t$options->setFormat($format);\n\t\t// evaluate if a valid location was given and is usable otherwise output to stdout\n\t\tif ($location !== null) {\n\t\t\t$handle = fopen($location, 'wb');\n\t\t\tif ($handle === false) {\n\t\t\t\tthrow new InvalidArgumentException(\"Location <$location> is not valid. Cannot open location for write operation.\");\n\t\t\t}\n\n\t\t\tforeach ($this->exportService->export($calendar, $options) as $chunk) {\n\t\t\t\tfwrite($handle, $chunk);\n\t\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/Command/ExportCalendar.php#L52-L88","documentation":"InvalidArgumentException thrown by occ dav:export-calendar (apps/dav/lib/Command/ExportCalendar.php:70) when the resolved calendar object does not implement OCP\\Calendar\\ICalendarExport. Only Nextcloud's own CalDAV calendars (CalendarImpl) know how to serialize to iCal/jCal/xCal; calendars contributed by apps via the calendar registry may not support export.","triggerScenarios":"occ dav:export-calendar alice <uri> where <uri> resolves to a plugin/external calendar (e.g. a read-only app calendar registered via ICalendarProvider) rather than a database-backed CalDAV calendar.","commonSituations":"App-provided calendars (birthday calendars from contacts apps, external app calendars); trying to export 'contact_birthdays'; custom apps registering ICalendar implementations without export support.","solutions":["Export only CalDAV-backed calendars (those visible under /remote.php/dav/calendars/<uid>/)","For app-provided read-only calendars, use that app's own export if any","Confirm the target with PROPFIND on the CalDAV home before choosing the uri argument"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"$calendars = $calendarManager->getCalendarsForPrincipal('principals/users/' . $uid, [$uri]);\n$exportable = array_filter($calendars, fn ($c) => $c instanceof \\OCP\\Calendar\\ICalendarExport);","typeGuard":"$isExportable = fn ($calendar): bool => $calendar instanceof \\OCP\\Calendar\\ICalendarExport;","tryCatchPattern":"try { $command->run(...); }\ncatch (\\InvalidArgumentException $e) {\n    if (str_contains($e->getMessage(), 'does not support exporting')) {\n        // target an app-internal export or a real CalDAV calendar\n    }\n}","preventionTips":["Check for ICalendarExport before offering export in tooling","Expect app/plugin calendars to be read-only presentation objects","Verify the URI belongs to /remote.php/dav/calendars before exporting"],"tags":["occ","cli","export","calendar","caldav","unsupported-operation","plugin-calendar"],"backgroundTag":"unsupported-operation","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}