A pipe in a DOCX table cell becomes a column separator in the extracted Markdown

オープン
#42,358 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

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

評価

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

調査の方向性

Start at WordExtractor._table_to_markdown, using the DOCX table reproduction in the issue to inspect how cell content is joined into Markdown rows. Compare the handling with core/rag/extractor/excel_extractor.py, then verify that the rendered table preserves the pipe as cell content and that the accompanying tests pass.

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

説明

Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.
Dify version

main (38f9d85d5a)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Add a .docx to a knowledge base that contains a table where a cell holds a | character. A pipe is ordinary content in a table cell: a regular expression (a|b), an "and/or" shorthand, a shell pipeline in a documentation table, or P(A|B) in a statistics table.

Two-column table:

Name Pattern
alternation a|b

WordExtractor._table_to_markdown renders it by joining the cells:

markdown.append("| " + " | ".join(headers) + " |")
markdown.append("| " + " | ".join(["---"] * total_cols) + " |")
for row in table.rows[1:]:
    row_cells = self._parse_row(row, image_map, total_cols)
    markdown.append("| " + " | ".join(row_cells) + " |")

Reproduced directly against the renderer:

>>> extractor = WordExtractor.__new__(WordExtractor)
>>> print(extractor._table_to_markdown(Document("t.docx").tables[0], {}))
| Name | Pattern |
| --- | --- |
| alternation | a|b |
✔️ Expected Behavior

The pipe inside the cell is escaped, so the row describes the same two columns as the header:

| Name | Pattern |
| --- | --- |
| alternation | a\|b |
❌ Actual Behavior

The cell's pipe is emitted as a column separator, so the last row claims three columns where the header declares two. From that row on, the table is misaligned: a renderer that trims to the header width drops the trailing cell, and a model reading the chunk sees a and b as two separate columns rather than one value.

Nothing fails and nothing is logged — the output is still a syntactically valid Markdown table, just not the table the document contains.

core/rag/extractor/excel_extractor.py already escapes the structural character of the format it emits — value.replace('"', '\\"'), in three places, so a quote inside a cell cannot corrupt the row — which is what makes the Markdown table renderer look like an oversight rather than a decision.

I have a fix and tests ready and will open a PR referencing this issue.


Transparency: this report was prepared with AI assistance. The reproduction above was run against the extractor at 38f9d85d5a and the output is copied verbatim from that run.

主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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