MarkdownReader throws ArgumentNullException on a table with an empty cell

オープン 初心者向け
#7,956 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
backend

調査の方向性

MarkdownParser.GetCellsから始め、単一ブロックの場合をMapBlockまで追います。スタックトレースから、空の段落を要素コンストラクターに渡す経路を特定します。テーブルセルに関する既存のパーサーテストを確認し、空のセルがnullにマッピングされ、空でないセルは引き続き解析されることを示すテストを追加します。報告されたテーブルが例外を出さずに読み込まれ、空のセルがnullとして表現されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area-ai untriaged

MarkdownReader throws when a Markdown table has an empty cell, so one empty cell fails the whole document.

Package: Microsoft.Extensions.DataIngestion.Markdig 11.0.0-preview.1.26560.3

var reader = new MarkdownReader();
using var stream = new MemoryStream(Encoding.UTF8.GetBytes("| a | b |\n| --- | --- |\n|  | 1 |\n"));
await reader.ReadAsync(stream, "doc", "text/markdown"); // throws

The same table with x in the empty cell reads fine.

System.ArgumentNullException: Value cannot be null. (Parameter 'markdown')
   at Microsoft.Extensions.DataIngestion.IngestionDocumentElement..ctor(String markdown)
   at Microsoft.Extensions.DataIngestion.IngestionDocumentParagraph..ctor(String markdown)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.MapLeafBlockToElement(LeafBlock block, Boolean previousWasBreak, String elementMarkdown)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.MapBlock(String documentMarkdown, Boolean previousWasBreak, Block block)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.GetCells(Table table, String outputContent)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.MapBlock(String documentMarkdown, Boolean previousWasBreak, Block block)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.Map(MarkdownDocument markdownDocument, String documentMarkdown, String identifier)
   at Microsoft.Extensions.DataIngestion.MarkdownParser.Parse(String markdown, String identifier)
   at Microsoft.Extensions.DataIngestion.MarkdownReader.ReadAsync(Stream source, String identifier, String mediaType, CancellationToken cancellationToken)

Markdig gives an empty cell one empty ParagraphBlock, so GetCells takes the 1 => branch rather than 0 => null. MapBlock then passes an empty string to IngestionDocumentParagraph, and IngestionDocumentElement's constructor rejects null or empty. The code is the same on main.

Empty cells are common in tables that come from PDFs, OCR and spreadsheets: in our corpus 5 of 16 documents failed to ingest this way. I'd expect an empty cell to map to null, like a cell with no blocks.

We work around it by writing U+200B into empty cells before reading and removing it from the chunks afterwards.

主要言語
C#
スター
3.3k
フォーク
919
平均マージ
2日 2時間
マージ済み PR(30日)
35

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/extensions のほかの issue

dotnet/extensions の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。