Skip to content

core - resolver - skip blank rows in value_from csv2dict - #11227

Merged
ajkerrigan merged 1 commit into
cloud-custodian:mainfrom
Thanatos9404:fix/9589-csv2dict-blank-rows
Oct 20, 2026
Merged

ajkerrigan merged 1 commit into
cloud-custodian:mainfrom
Thanatos9404:fix/9589-csv2dict-blank-rows

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #9589

A blank line in a file read through value_from with format: csv2dict made the whole lookup come back empty. csv.reader returns an empty row for it, and csv2dict transposes the rows with zip(*rows), so one empty row produces {}.

#10880 fixed the plain csv format 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 like 222,, 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.

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
@Thanatos9404
Thanatos9404 requested review from a team and kapilt as code owners October 19, 2026 06:06

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@ajkerrigan ajkerrigan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good 👍

@ajkerrigan
ajkerrigan merged commit b377a9d into cloud-custodian:main Oct 20, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank lines break value_from's csv/csv2dict formats

2 participants