Contacts import aborts with TypeError when vCards have no UID (TextImporter structure)
メンテナーはふだん 1 日以内に返信
@SebastianKrupinski がすでに取り組んでいます。
2026年11月10日 から。
評価
調査の方向性
apps/dav/lib/CardDAV/Import/TextImporter.php の analyze() から始めます。ここでは UID のないコンポーネントがリストではなく素のインスタンスとして保存されています。次に、75 行目付近の ImportService::importText() を確認します。これは $instances[0] を読み取ります。修正は、UID のないエントリをリストでラップすることであり、同じパターンを apps/dav/lib/CalDAV/Import/TextImporter.php でも確認する必要があります。UID のない vCard が正常にインポートされることを、apps/dav のインポートテストで検証できたら完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 37.5k
- フォーク
- 5.4k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 648
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
Unified search: screen reader hears "No matching results" on mobile even when there are results対応中かも @lazerg が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
34-feedback needs info
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
nextcloud/server#66249 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: DAV Forbidden/InvalidPath responses break on "&" in the message (DOMDocument::createElementNS(): unterminated entity reference)対応中かも @th-joerger が 12 日前に担当しました。 オープン0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
wpgenius/stackfolio#22 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信