nextcloud/server · error · InvalidArgumentException
Error importing calendar data: One or more objects discovere
Error message
Error importing calendar data: One or more objects discovered with multiple base component types
What it means
Thrown when an imported calendar object contains more than one base component and they are not all of the same type (for example a VEVENT and a VTODO in one VCALENDAR). CalDAV requires each stored resource to hold components of a single type, so ImportService rejects mixed-type objects when the error mode is ERROR_FAIL. In a non-failing mode it yields an ImportObjectEvent with disposition Error and continues with the next object.
Source
Thrown at apps/dav/lib/CalDAV/Import/ImportService.php:298
throw new InvalidArgumentException('Error importing calendar data: ' . $errorMessage);
}
yield new ImportObjectEvent(
disposition: ImportDisposition::Error,
identifier: null,
errors: [$errorMessage]
);
continue;
}
// determine if the object has more than one base component type
// object can have multiple base components with the same uid
// but we need to make sure they are of the same type
if (count($components) > 1) {
$type = $components[0]->name;
foreach ($components as $entry) {
if ($type !== $entry->name) {
$errorMessage = 'One or more objects discovered with multiple base component types';
if ($options->getErrors() === $options::ERROR_FAIL) {
throw new InvalidArgumentException('Error importing calendar data: ' . $errorMessage);
}
yield new ImportObjectEvent(
disposition: ImportDisposition::Error,
identifier: null,
errors: [$errorMessage]
);
continue 2;
}
}
}
// determine if the object has a uid
if (!isset($components[0]->UID)) {
$errorMessage = 'One or more objects discovered without a UID';
if ($options->getErrors() === $options::ERROR_FAIL) {
throw new InvalidArgumentException('Error importing calendar data: ' . $errorMessage);
}
yield new ImportObjectEvent(
disposition: ImportDisposition::Error,View on GitHub (pinned to ecdeb153ff)
Solutions
- Split the offending VCALENDAR block so each object contains only components of one type, keeping the shared UID only within a single type
- Run the import with errors below ERROR_FAIL and handle the yielded Error events so the rest of the file still imports
- Pre-scan with sabre/vobject: collect getBaseComponents() names and verify they are uniform before importing
Example fix
// before
$vObject = \Sabre\VObject\Reader::read($ics);
// mixed VEVENT+VTODO object -> import() throws
// after
$vObject = \Sabre\VObject\Reader::read($ics);
$types = array_unique(array_map(fn ($c) => $c->name, $vObject->getBaseComponents()));
if (count($types) > 1) {
// split per type into separate VCALENDAR objects before import
} Defensive patterns
Strategy: validation
Validate before calling
$v = \Sabre\VObject\Reader::read($ics);
$names = array_map(fn ($c) => $c->name, $v->getBaseComponents());
if (count(array_unique($names)) > 1) {
// split into one VCALENDAR per component type before importing
} Type guard
function hasUniformBaseComponents(\Sabre\VObject\Component\VCalendar $v): bool {
$names = array_map(fn ($c) => $c->name, $v->getBaseComponents());
return count(array_unique($names)) <= 1;
} Try / catch
try {
foreach ($service->import($source, $calendar, $options) as $event) {}
} catch (\InvalidArgumentException $e) {
// identify the mixed-type object, split it, re-import
} Prevention
- When merging calendars, group components by type as well as UID
- Test importers with fixtures containing recurring events plus exceptions (correct) and mixed-type objects (must split)
- Keep error mode below ERROR_FAIL during bulk imports
When it happens
Trigger: Importing data where one VCALENDAR block groups a recurring event with its VTODO sibling under the same UID (or any VEVENT+VTODO/VJOURNAL mix) while options->getErrors() === CalendarImportOptions::ERROR_FAIL.
Common situations: Merging event and task data into one calendar file; exports from tools that bundle related components of different types together; broken object splitting in a custom exporter.
Related errors
- Error importing calendar data: One or more objects discovere
- Error importing calendar data: One or more objects discovere
- Invalid node
- Error importing calendar data: UID <$uid> - $issues[0]
- Error importing calendar data: UID <$uid> - $errorMessage
AI-assisted analysis of nextcloud/server@ecdeb153ff (2026-08-17).
Data as JSON: /api/errors/9af9ec9c074e79a1.
Report an issue: GitHub.