Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)
Los mantenedores suelen responder en 1 día
@SebastianKrupinski ya está trabajando en esto.
Desde el 10/11/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Empieza en apps/dav/lib/CardDAV/Import/TextImporter.php, en analyze(), donde los componentes sin UID se almacenan como instancias simples en lugar de listas. Luego revisa ImportService::importText() alrededor de la línea 75, que lee $instances[0]. La corrección consiste en envolver la entrada sin UID en una lista, y el mismo patrón debe revisarse en apps/dav/lib/CalDAV/Import/TextImporter.php. Terminado cuando una vCard sin UID se importa correctamente, verificado con una prueba en las pruebas de importación de apps/dav.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug description
Importing a .vcf file in the Contacts app ("Import contacts") fails completely ("0 of 629 imported") when the vCards have no UID property. A Google Contacts export is the typical case: none of its 629 cards had a UID.
The server log shows:
TypeError: OCA\DAV\CardDAV\Import\TextImporter::extract(): Argument #1 ($start) must be of type int, string given,
called in apps/dav/lib/CardDAV/Import/ImportService.php on line 75
(request: /ocs/v2.php/contacts/import)
Cause
In apps/dav/lib/CardDAV/Import/TextImporter.php::analyze(), a component with a UID is stored as a list of instances:
$this->structure[$componentType][$componentId][] = [$componentType, $componentId, $componentStart, $componentEnd];
A component without a UID is stored as a bare instance, not wrapped in a list:
$this->structure[$componentType][] = [$componentType, $componentId, $componentStart, $componentEnd];
ImportService::importText() expects a list of instances in both cases:
foreach ($structure['VCARD'] as $cid => $instances) {
$instance = $instances[0]; // "VCARD" (string) for UID-less cards
$sObjectContents = $importer->extract($instance[2], $instance[3]); // "A", "R" -> TypeError
The generator throws on the first UID-less card, so the whole import is aborted.
The same pattern exists in apps/dav/lib/CalDAV/Import/TextImporter.php. There, ImportService casts the values with (int), so it does not throw, but it would read wrong byte ranges.
Steps to reproduce
- Create
test.vcf:BEGIN:VCARD VERSION:3.0 FN:Erika Mustermann N:Mustermann;Erika;;; TEL;TYPE=CELL:+49 170 0000000 END:VCARD - Contacts → Contacts settings → Import contacts → choose
test.vcf. - Result: "0 of 1 imported", with the TypeError above in
nextcloud.log.
Adding a UID: line to each card makes the import succeed. I verified this with the original file: all 629 cards imported.
Expected behavior
vCards without a UID are imported. A UID is optional in vCard 3.0, and the CardDAV backend can generate one.
Suggested fix
Wrap the UID-less entry in a list as well, for example:
$this->structure[$componentType][] = [[$componentType, $componentId, $componentStart, $componentEnd]];
The same applies to the CalDAV TextImporter.
Versions
- Nextcloud 35.0.2 (Docker image
nextcloud:35-apache), PHP 8.5.12, MariaDB 11.4 - Contacts app 8.9.5
- The same code is in
master,stable35andstable34as of today.
- Lenguaje dominante
- PHP
- Estrellas
- 37.5k
- Forks
- 5.4k
- Merge medio
- 1 d 14 h
- PR fusionados (30 d)
- 648
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextcloud/server
-
0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Unified search: screen reader hears "No matching results" on mobile even when there are resultsPosiblemente ocupada @lazerg la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
34-feedback needs info
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
nextcloud/server#66249 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)Posiblemente ocupada @th-joerger la tomó hace 12 días. Abierto0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/server
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
wpgenius/stackfolio#22 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día