deepset-ai / deepset-ai/haystack
CSVToDocument row mode overwrites a CSV column named row_number
@anakin87 is already working on this.
Since Sep 17, 2026.
- Dominant language
- Python
- Stars
- 26.6k
- Forks
- 3.2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 194
Description
Describe the bug
In CSVToDocument(conversion_mode="row"), a CSV column named row_number is silently lost when another column supplies the document content. The generated zero-based index overwrites the original value after the other columns have been merged into metadata.
Reproduce
from haystack.components.converters.csv import CSVToDocument
from haystack.dataclasses import ByteStream
source = ByteStream(data=b"text,row_number\nhello,record-42\n")
doc = CSVToDocument(conversion_mode="row").run(
sources=[source], content_column="text"
)["documents"][0]
print(doc.meta)
# Actual: {'row_number': 0}
# Expected: {'row_number': 0, 'csv_row_number': 'record-42'}
Other metadata collisions already use the csv_ prefix and numeric suffixes. Reserving the generated row_number before merging CSV columns lets that same logic preserve this column too. Selecting row_number itself as the content column should keep working.
This affects source record identifiers during RAG ingestion; there is no warning that the original identifier was dropped.
Validation
Two regression cases fail with data-loss assertions before the fix: the ordinary case and a case with occupied csv_row_number / csv_row_number_1 metadata keys. A control with content_column="row_number" passes before and after. All 20 CSV converter tests pass after the fix.
Windows, Python 3.12.14, Haystack 3.2.0rc0. Source blob 9a4a102da546c8cf1e9c162e20dfed52bbb681c5 was verified unchanged on current main. Tests use local ByteStreams and Hatch; no model or network calls are needed.
Prepared and tested with Codex. No human review is claimed.
Contributor 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.
Assessment
This issue has not been assessed yet.