Skip to content

fix(cli): strip CR inside quoted CSV fields, not just outside them - #947

Open
AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/csv-import-crlf-in-quoted-fields
Open

fix(cli): strip CR inside quoted CSV fields, not just outside them#947
AmirF194 wants to merge 1 commit into
tokencanopy:mainfrom
AmirF194:fix/csv-import-crlf-in-quoted-fields

Conversation

@AmirF194

Copy link
Copy Markdown
Contributor

Summary

parseCSV (cli/src/commands/contacts.ts) drops every \r unconditionally
outside a quoted field, but inside a quoted field it appends \r to the
field verbatim. The function's own docstring claims RFC 4180 conformance
specifically for CRLF exports from Sheets/Excel/CRMs, and a Windows- or
Excel-produced multi-line cell uses CRLF line breaks internally too, so
importing one via e2a contacts import bakes a stray carriage return into
stored contact metadata.

Fix mirrors the existing unquoted branch: drop \r inside a quoted field
the same unconditional way, instead of appending it.

Test plan

  • New regression test (normalizes CRLF to LF inside a quoted multi-line field instead of leaking a raw CR) fails on unmodified
    main and passes on this branch, both runs in a clean node:22-slim
    container.
  • Full npm run test:coverage --workspace @e2a/cli (322 tests) green.
  • npm run build --workspace @e2a/cli and npm run typecheck --workspace @e2a/cli both clean.
  • Not checked: the live e2a contacts import path end to end against a
    real API server; this is covered at the parseCSV unit level only.

parseCSV's docstring claims RFC 4180 conformance for CRLF exports from
Sheets, Excel, and CRMs. Outside a quoted field the parser drops every
\r unconditionally, but inside a quoted field it appends \r to the
field verbatim, so a Windows/Excel-produced multi-line cell (CRLF line
breaks) imported via `e2a contacts import` bakes a stray carriage
return into stored contact metadata. Mirrors the existing unquoted
branch's unconditional \r drop.
@AmirF194
AmirF194 requested a review from jiashuoz as a code owner August 28, 2026 00:56
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