CSVToDocument row mode drops a real extra_columns field on ragged rows
CSVToDocument(conversion_mode="row") uses extra_columns as the csv.DictReader rest key. If the CSV also has a column named extra_columns, a row with surplus fields overwrites that column before the converter sees it. The output document keeps the overflow values but silently loses the original field.
from haystack.components.converters.csv import CSVToDocument
from haystack.dataclasses import ByteStream
source = ByteStream(data=b"text,extra_columns\r\nhello,real value,overflow\r\n")
doc = CSVToDocument(conversion_mode="row").run(
sources=[source], content_column="text"
)["documents"][0]
print(doc.content, doc.meta)
# hello {'extra_columns': "['overflow']", 'row_number': 0}I ran this twice on current main; both runs produced the same result. The original real value cannot be recovered from the document. extra_columns is a valid CSV header, and an extra trailing delimiter or unquoted comma is enough to trigger this in row mode. File mode is unaffected.
Could the rest key use a name that cannot collide with a CSV header, or could the converter separate surplus fields before building metadata? A regression test should cover a real extra_columns column alongside overflow values. This is related to the ragged-row fix in #11944, but that fix only tests a header without this name. I can prepare the patch if the maintainers want one.
Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!
Source: deepset-ai/haystack