Repository navigation
[pkl.csv] Report empty header columns clearly - #243
Open
abhiishek340 wants to merge 3 commits into
Open
abhiishek340 wants to merge 3 commits into
abhiishek340 wants to merge 3 commits into
Conversation
Parsing with `includeHeader = true` failed with "Expected value of type `String`, but got `null`" when a header cell was empty. The common cause is input that uses "\n" line breaks while `lineBreak` defaults to "\r\n": the whole input is parsed as one row, so an empty cell in a later line becomes part of the header. Pkl multi-line strings use "\n", which is how the input in apple#76 was written. Report which header column is empty, and when the input contains "\n" but no `lineBreak`, suggest setting `lineBreak = "\n"`. Closes apple#76
bioball
approved these changes
Oct 16, 2026
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.
Closes #76.
Empty cells already parse correctly when the input's line breaks match
lineBreak:The failure in #76 comes from line breaks.
lineBreakdefaults to"\r\n"(RFC 4180), and the input in the issue is a Pkl multi-line string, which uses"\n". With no"\r\n"in the input, it's parsed as a single row. The empty cell from the second line then lands in the header, and theas List<String>?cast fails with:This PR replaces that with a message that names the problem and, when the input contains
"\n"but nolineBreak, how to fix it:A header with a genuinely empty column (
"A,,C\r\n1,2,3") gets just the first sentence.I didn't change the default line break or start accepting both, since that changes parsing semantics. Happy to do that instead if you'd prefer.
Changes:
csv.pkl: check the header row for empty columns before the cast, plus a_lineBreakHintfor the single-row case.tests/csv_test.pkl: new "Parsing with an empty header column" fact covering both messages and thelineBreak = "\n"case.PklProject: bumppkl.csvto 1.1.2. No other package depends onpkl.csv.Testing:
pkl test packages/pkl.csv/tests/csv_test.pklpasses with Pkl 0.32.1 (the version inlibs.versions.toml) and with pkl main: 13 tests, 55 assertions.pkl format(0.32.1) reports no changes in the new code. The three lines it does flag incsv.pklwere already flagged onmain, so I left them alone.