Skip to content

52: Email send script#16

Open
isabellalam12 wants to merge 4 commits into
mainfrom
52
Open

52: Email send script#16
isabellalam12 wants to merge 4 commits into
mainfrom
52

Conversation

@isabellalam12
Copy link
Copy Markdown

No description provided.

@isabellalam12 isabellalam12 requested a review from a team as a code owner May 30, 2026 02:52
@graphite-app graphite-app Bot requested review from Arshadul-Monir and arklian May 30, 2026 02:53
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 30, 2026

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()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

  1. Incorrect column counts
  2. Misaligned field mappings
  3. 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 
});
Suggested change
const csvArray = lines.map(line => line.split(",").map(cell => cell.trim()));
const csvArray = parse(data, {
skip_empty_lines: true,
trim: true
});

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Copy Markdown
Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

row[headerIndex['Topics']],
row[headerIndex['Anything']]
);
usersMap[email] = user;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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);
Suggested change
usersMap[email] = user;
usersMap.set(email, user);

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Comment thread js/src/app/user/admin/emails/CsvParse.js
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant