Repository navigation
writer: keep the writer usable after an UnequalLengths error - #439
Open
patrick-immometrica wants to merge 1 commit into
Open
patrick-immometrica wants to merge 1 commit into
patrick-immometrica wants to merge 1 commit into
Conversation
With `flexible(false)`, a record with the wrong number of fields returned `UnequalLengths` before the terminator was written and without resetting the field counter. The record's fields were already in the buffer, so the next record got glued onto it and every following write failed too, since the counter kept growing. Now the terminator is written and the counter reset before the error is returned, so the writer stays usable.
patrick-immometrica
marked this pull request as ready for review
November 14, 2026 11:11
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.
With the default
flexible(false), one record with the wrong field count breaks every write after it:The check runs before the terminator is written and
fields_writtenis never reset, so the bad record's fields stay in the buffer, the next record is appended to the same line and the count only grows from there.Rolling the record back isn't possible since
write_fieldmay already have flushed part of it, so this writes the terminator and resets the counter first, then returns the error. The bad record still ends up in the output (as before), but it is on its own line and later records are fine.Added a test covering both
write_recordandwrite_byte_record.