Skip to content

fix(destination-google-sheets): sanitize " in cell values to prevent pasteData column misalignment #357

Draft
sgresh-stripe wants to merge 2 commits intomainfrom
sgresh/character-escaping
Draft

fix(destination-google-sheets): sanitize " in cell values to prevent pasteData column misalignment #357
sgresh-stripe wants to merge 2 commits intomainfrom
sgresh/character-escaping

Conversation

@sgresh-stripe
Copy link
Copy Markdown

Problem

A customer whose description field contained embedded JSON (e.g. {"custom_fields":null,"default_payment_method":null,...}) caused the 6 columns after description to go missing from every written row.

Root cause: The Google Sheets pasteData API applies RFC 4180-like CSV quoting semantics even when a custom delimiter (U+001F) is specified. An unescaped " mid-cell causes the server-side parser to enter quoted-field mode, absorbing subsequent \x1f delimiters as literal content instead of column separators — which drops every column after the affected cell.

Fix

Add " to PASTE_SANITIZE_RE in sanitizeForPaste. Double-quotes are replaced with ' (single-quote) rather than a space to keep JSON-serialized values readable ({"key":null}{'key':null}).

Tests

  • Unit: rowsToTsv with a row containing the exact customer description from the report — asserts no raw " in TSV output and all 8 cells are still delimited correctly.
  • Integration: full destination write with that description value — asserts the data row has the same column count as the header row and that " does not appear in the written cell.
  • Updated the existing value stringification test whose expected JSON literal now reflects the sanitized form (' instead of ").

sgresh-stripe and others added 2 commits May 4, 2026 21:16
… to prevent pasteData column misalignment

The Google Sheets pasteData API applies RFC 4180-like quoting semantics
even when a custom delimiter (U+001F) is used. An unescaped `"` mid-value
causes the server-side parser to enter quoted-field mode and absorb
subsequent \x1f delimiters as content rather than column separators,
silently dropping the columns that follow.

A customer whose description field contained embedded JSON (e.g.
`{"custom_fields":null,"default_payment_method":null,...}`) triggered
this: the 6 columns after the description were missing from the written
row.

Fix: add `"` to PASTE_SANITIZE_RE; replace with `'` to preserve
readability. Adds two regression tests — a rowsToTsv unit test asserting
no raw double-quotes in the output, and a full-destination integration
test verifying row column count is preserved.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
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