Repository navigation
core - resolver - skip blank rows in value_from csv2dict - #11227
Merged
ajkerrigan merged 1 commit intoOct 20, 2026
Merged
Conversation
csv.reader returns an empty row for a blank line. The csv2dict format transposes the rows with zip(*rows), so a single empty row made zip() stop straight away and the parsed dict came out empty. A key expr such as account_id then resolved to None with only a warning, and the lookup behaved as if the file had no data. Skip empty rows before transposing, the same way the csv column lookup has done since cloud-custodian#10880. Rows with content, including short rows and rows with empty cells, are passed through unchanged. Fixes cloud-custodian#9589
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.
Summary
Fixes #9589
A blank line in a file read through
value_fromwithformat: csv2dictmade the whole lookup come back empty.csv.readerreturns an empty row for it, and csv2dict transposes the rows withzip(*rows), so one empty row produces{}.#10880 fixed the plain
csvformat by skipping empty rows and left csv2dict as it was. This PR does the same for csv2dict: empty rows are skipped before the transpose, and rows with any content, including empty cells like222,, are kept.Testing
Added five tests to
tests/test_resolver.py, written inline like the ones in #10880. The four blank-row tests fail on main and pass with this change; the fifth guards short rows.Not changed: a non-empty row with fewer cells than the header still cuts the other rows short, as before. I can follow up on that separately.