Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)
Maintainer thường phản hồi trong vòng 1 ngày
@SebastianKrupinski đang làm issue này rồi.
Từ ngày 10/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu trong apps/dav/lib/CardDAV/Import/TextImporter.php, trong analyze(), nơi các component không có UID được lưu dưới dạng instance trần thay vì danh sách. Sau đó kiểm tra ImportService::importText() quanh dòng 75, chỗ đọc $instances[0]. Cách sửa là bọc mục không có UID trong một danh sách, và cùng kiểu mẫu đó cần được kiểm tra trong apps/dav/lib/CalDAV/Import/TextImporter.php. Hoàn tất khi một vCard không có UID được import thành công, xác minh bằng một test trong các test import của apps/dav.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 37.5k
- Fork
- 5.4k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 648
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/server
-
0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Unified search: screen reader hears "No matching results" on mobile even when there are resultsCó thể đã có người làm @lazerg đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
34-feedback needs info
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
nextcloud/server#66249 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)Có thể đã có người làm @th-joerger đã nhận 12 ngày trước. Đang mở0. Needs triage 35-feedback bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của nextcloud/server
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
wpgenius/stackfolio#22 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày