CSVToDocument accepts an unsupported conversion_mode and silently converts in row mode
メンテナーはふだん 1 日以内に返信
@Lesereingrape がすでに取り組んでいます。
2026年10月2日 から。
評価
調査の方向性
haystack/components/converters/csv.py の CSVToDocument.init から始め、haystack/components/converters/xlsx.py の 82-86 行目とそのバリデーションを比較してください。conversion_mode の実行時バリデーションを追加し、準備したテストでサポートされていない値を網羅して、有効なファイルモードと行モードが引き続き機能し、無効な値が構築時に失敗することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
CSVToDocument never validates conversion_mode. __init__ stores the value as given (haystack/components/converters/csv.py:75) and its "Basic validation" block only checks delimiter and quotechar (line 79). run() then dispatches on a single equality test against "file" (line 142), so any other value falls into the row branch.
The parameter is annotated Literal["file", "row"], but at runtime a typo — or a value that differs only in case or trailing whitespace, which is common when the component is loaded from a saved pipeline YAML — is accepted and silently changes what the converter produces: one Document per CSV row instead of one per file.
Error message
No error is raised for conversion_mode="Rows"; the pipeline just converts differently. When content_column is not passed to run(), the failure that eventually surfaces names a mode the caller never configured, which points the reader at the wrong branch:
ValueError: CSVToDocument(row): 'content_column' is required in run() when conversion_mode='row'.
Measured on main at 9f31fb4b, for the same three-row CSV:
conversion_mode |
run(..., content_column="title") |
documents produced |
|---|---|---|
"file" |
documented value | 1 — 'title,author\nDune,Frank Herbert\nNeuromancer,Gibson\n' |
"Rows" |
typo | 2 — 'Dune', 'Neuromancer' |
"FILE" |
case typo | 2 — 'Dune', 'Neuromancer' |
"row " |
trailing space | ValueError quoting conversion_mode='row' |
Expected behavior
Constructing the component with a value outside Literal["file", "row"] should fail fast in __init__, the way the sibling XLSXToDocument already validates its own Literal parameters in its constructor (haystack/components/converters/xlsx.py:82-86 checks table_format and link_format):
ValueError: CSVToDocument: unsupported conversion_mode 'Rows'. Choose 'file' or 'row'.
That keeps the documented type contract true at runtime and turns a silent per-row conversion into an immediate, actionable error.
To Reproduce
from haystack.components.converters import CSVToDocument
from haystack.dataclasses import ByteStream
csv = "title,author\nDune,Frank Herbert\nNeuromancer,Gibson\n"
sources = [ByteStream.from_string(csv)]
# 1. silent wrong behaviour: "Rows" != "file", so run() takes the row branch
docs = CSVToDocument(conversion_mode="Rows").run(sources=sources, content_column="title")["documents"]
print(len(docs)) # 2, not 1
print(docs[0].content) # 'Dune'
# 2. misleading error message naming a mode that was never configured
CSVToDocument(conversion_mode="row ").run(sources=sources)
# ValueError: CSVToDocument(row): 'content_column' is required in run() when conversion_mode='row'.
Additional context
conversion_mode is part of the serialized component config, so a misspelled value can be loaded from a saved pipeline YAML without ever passing through a type checker, and the wrong-mode output flows into the rest of the indexing pipeline unnoticed.
I read the source while looking for the same unvalidated-Literal pattern the XLSXToDocument constructor guards against, and have a two-line validation plus tests prepared locally (reproduced RED on main, GREEN with the change).
FAQ Check
- Have you had a look at our new FAQ page?
System:
- OS: Windows 11
- Haystack version: 3.3.0-rc0 (editable install of
main@9f31fb4b), Python 3.11.14
- 主要言語
- Python
- スター
- 27.1k
- フォーク
- 3.5k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 239
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
deepset-ai/haystack のほかの issue
-
BlockingConfirmationStrategy ignores an empty argument replacement対応中かも @Aarkin7 が 3 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
deepset-ai/haystack#13863 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
P2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
deepset-ai/haystack#13830 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
DocumentSplitter misplaces repeated literal chunks from an overlapping custom splitter対応中かも @davidsbatista が 7 日前に担当しました。 オープンP2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepset-ai/haystack#13806 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
InMemoryDocumentStore: count_unique_metadata_by_filter and get_metadata_field_unique_values disagree on int/float/bool values対応中かも @sjrl が 14 日前に担当しました。 オープンP3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepset-ai/haystack#13040 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
CSVToDocument row mode fails on CR-separated CSV input対応中かも @julian-risch が 55 日前に担当しました。 オープンP3
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
deepset-ai/haystack#13022 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
deepset-ai/haystack の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
micronaut-projects/micronaut-core#14585 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
langgenius/graphon#443 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
docling-project/docling-serve#788 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
opensearch-project/cross-cluster-replication#1805 ·
メンテナーはふだん 1 日以内に返信