52: Email send script#16
Conversation
Graphite Automations"Request reviewers once CI passes" took an action on this PR • (05/30/26)2 reviewers were added to this PR based on Henry Chen's automation. |
| const data = fs.readFileSync(csv, "utf-8"); | ||
|
|
||
| const lines = data.split("\n").map(line => line.trim()).filter(line => line.length > 0); | ||
| const csvArray = lines.map(line => line.split(",").map(cell => cell.trim())); |
There was a problem hiding this comment.
Critical CSV parsing bug. Using split(",") will incorrectly parse CSV fields that contain commas within quotes. The test data includes fields like "Tahmid is a senior at Hunter College & has been interning at Integral Ad Science for close to a year now, as well as running various software projects for Patina. Tahmid likes to eat good food :)" which contains commas. This will cause:
- Incorrect column counts
- Misaligned field mappings
- Runtime errors when accessing
row[headerIndex['Email']](line 43) due to wrong indices
Fix: Use a proper CSV parsing library:
import { parse } from 'csv-parse/sync';
// Then replace lines 29-30 with:
const csvArray = parse(data, {
skip_empty_lines: true,
trim: true
});| const csvArray = lines.map(line => line.split(",").map(cell => cell.trim())); | |
| const csvArray = parse(data, { | |
| skip_empty_lines: true, | |
| trim: true | |
| }); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
| row[headerIndex['Topics']], | ||
| row[headerIndex['Anything']] | ||
| ); | ||
| usersMap[email] = user; |
There was a problem hiding this comment.
Critical Bug: Incorrect Map usage
Using bracket notation on a Map object doesn't add entries to the Map. This creates a regular object property instead, so the Map will remain empty and subsequent lookups will fail.
// Wrong:
usersMap[email] = user;
// Correct:
usersMap.set(email, user);| usersMap[email] = user; | |
| usersMap.set(email, user); |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
|




No description provided.