Repository navigation
reject colwise csv map rows with more cells than columns - #2994
Merged
stephenberry merged 2 commits intoOct 15, 2026
Merged
Conversation
Owner
|
Thanks for the fix! I pushed a small cleanup: the row ending now uses |
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.
The colwise reader for std::map<std::string, std::vector> (from<CSV, readable_map_t>::op in include/glaze/csv/read.hpp) advances its per-row loop only past a comma, CR, or LF once it has read n_keys cells, and never looks at ctx.error between fields. A data row carrying more cells than there are header columns, or a field the reader stopped on a stray byte, leaves the iterator on a byte neither the delimiter nor the newline branch consumes, so the outer while(it != end) loop makes no progress.
Before,
a,b\n1,2,3\ninto a string-valued map read as success with the third cell misassigned to a second row of column a and an empty inserted into b, and the same row of a numeric map set parse_number_failure that the loop dropped and then spun on, emplacing default elements. After, both are a syntax_error. The fix bails on ctx.error after each field and rejects a row not closed by a newline or end of input, which is what the sibling colwise struct reader and the rowwise readers already do; keeping the check in this loop is why the four readers now agree on what a row is. The tradeoff is that a row with trailing content past its columns is now refused rather than partially consumed; a well-formed document, including a last row with no trailing newline, is unchanged.