Skip to content

feat: add import contacts command#253

Open
ishtails wants to merge 3 commits intoresend:mainfrom
ishtails:main
Open

feat: add import contacts command#253
ishtails wants to merge 3 commits intoresend:mainfrom
ishtails:main

Conversation

@ishtails
Copy link
Copy Markdown

@ishtails ishtails commented Apr 11, 2026

  • Introduced importContactsCommand to the contacts command module.
  • Updated command examples to include usage of the new import feature.
  • Added tryParsePropertiesJsonObject utility function for improved JSON parsing, enhancing error handling in parsePropertiesJson function.

Summary by cubic

Adds a CSV import command to bulk-create contacts and optionally add them to segments. Tightens CSV/JSON validation for clearer errors and smoother imports.

  • New Features

    • New resend contacts import --file <path> [--segment-id <id>...].
    • Requires email/e-mail; optional first_name, last_name, properties (JSON per cell); header normalization.
    • Imports up to 5 rows concurrently; reports successes and failed rows; exits 1 if any fail.
    • RFC 4180 CSV parsing with BOM handling; command registered and examples updated.
  • Bug Fixes

    • CSV import now ignores empty rows and fails fast if the email header is missing to prevent invalid records.
    • parsePropertiesJson rejects non-object/invalid JSON with a clear invalid_properties error (via tryParsePropertiesJsonObject).

Written for commit fb6b1d0. Summary will update on new commits.

- Introduced `importContactsCommand` to the contacts command module.
- Updated command examples to include usage of the new import feature.
- Added `tryParsePropertiesJsonObject` utility function for improved JSON parsing, enhancing error handling in `parsePropertiesJson` function.
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/commands/contacts/import.ts">

<violation number="1" location="src/commands/contacts/import.ts:70">
P2: CSV validation wrongly depends on the first data row’s email value instead of the header, so a valid import file can be rejected outright.</violation>
</file>

<file name="src/lib/parse-csv.ts">

<violation number="1" location="src/lib/parse-csv.ts:44">
P2: Unquoted `"` characters start quoted parsing mid-field, which can silently shift CSV columns and corrupt imported data.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread src/commands/contacts/import.ts Outdated
Comment thread src/lib/parse-csv.ts
}

switch (c) {
case '"':
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 11, 2026

Choose a reason for hiding this comment

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

P2: Unquoted " characters start quoted parsing mid-field, which can silently shift CSV columns and corrupt imported data.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/parse-csv.ts, line 44:

<comment>Unquoted `"` characters start quoted parsing mid-field, which can silently shift CSV columns and corrupt imported data.</comment>

<file context>
@@ -0,0 +1,72 @@
+    }
+
+    switch (c) {
+      case '"':
+        inQuotes = true;
+        i++;
</file context>
Fix with Cubic

@ishtails ishtails changed the title feat: add import contacts command and enhance JSON parsing utility feat: add import contacts command Apr 11, 2026
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