fix: CSVToDocument row mode no longer crashes the batch on a row with extra fields - #11944
Merged
sjrl merged 1 commit intoJul 10, 2026
Conversation
|
@Otis0408 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Pass an explicit restkey to csv.DictReader so surplus fields on rows with more values than the header land under an 'extra_columns' key instead of the default None key, which broke Document id generation and aborted the whole batch.
otiscuilei
force-pushed
the
fix/csv-to-document-row-mode-extra-fields
branch
from
July 10, 2026 06:02
e8408bd to
daf87cc
Compare
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anyone using
CSVToDocumentwithconversion_mode="row"on real-world CSV data hits this: a single data row that contains more fields than the header aborts the entirerun()call. This happens with genuinely ragged files, an extra trailing delimiter, or the very common case of an unquoted comma inside a value.The converter parses rows with
csv.DictReaderusing the defaultrestkey=None. Surplus fields on an over-long row are collected under the Python keyNone, and_build_document_from_rowcopies every row key intoDocument.meta. When theDocumentis constructed,Document._create_id()runsjson.dumps(self.meta, sort_keys=True, ...), and sorting aNonekey againststrkeys raisesTypeError: '<' not supported between instances of 'NoneType' and 'str'. The converter wraps this in aRuntimeErrorand re-raises, so the whole batch fails: every other source is skipped and any Documents already built from earlier valid sources are discarded. (File mode is unaffected because it never parses rows.)The fix passes an explicit string
restkey="extra_columns"tocsv.DictReader, so surplus values land under a normal string metadata key instead ofNone. Document id generation then works and the surplus data is preserved rather than crashing the run.Before:
After:
A regression test (
test_row_mode_ragged_row_does_not_crash) feeds a ragged row alongside a valid source and asserts both Documents are produced (the earlier valid source is no longer lost) and that the surplus value is stored under a non-Nonemeta key. It fails on the pre-fix code with theTypeError/RuntimeErrorand passes with the fix.A release note is included at
releasenotes/notes/csv-to-document-row-mode-extra-fields-d4e5f60718293041.yaml.