MarkdownReader throws ArgumentNullException on a table with an empty cell
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in MarkdownParser.GetCells and follow its single-block case into MapBlock; the stack trace identifies the path that sends an empty paragraph to the element constructor. Check existing parser tests for table cells and add coverage showing an empty cell maps to null while nonempty cells still parse. Done when the reported table reads without throwing and the empty cell is represented as null.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C#
- Stars
- 3.3k
- Forks
- 919
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 35
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/extensions
-
area-ai bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/extensions#7954 ·
Maintainers usually reply within 1 day
-
ServiceEndpointWatcher logs normal cancellation as an errorPossibly taken @seragAhmed claimed this 5 days ago. Openbug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
dotnet/extensions#7940 · 1 comment ·
Maintainers usually reply within 1 day
-
OpenAISpeechToTextClient sends Ogg MemoryStream audio with an .mp3 filenamePossibly taken @Manish-1kumar claimed this 17 days ago. Openarea-ai untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dotnet/extensions#7900 · 1 comment ·
Maintainers usually reply within 1 day
-
Unable to obtain the UsageContent and FinishReason of response.incompletePossibly taken @jaeminbird claimed this 20 days ago. Openarea-ai bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
dotnet/extensions#7893 ·
Maintainers usually reply within 1 day
-
AI Chat Web template: scaffolded Identity pages are inaccessible because App.razor applies an interactive render mode unconditionallyPossibly taken @valkiara claimed this 20 days ago. Openarea-ai-templates untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
dotnet/extensions#7889 · 1 comment ·
Maintainers usually reply within 1 day
All issues in dotnet/extensions
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area/backend type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
umbraco/Umbraco-CMS#24668 · 1 comment ·
Maintainers usually reply within 1 day
-
Pri3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MicrosoftDocs/windows-dev-docs#6205 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
filiptrivan/spiderly#474 ·
Maintainers usually reply within 2 days