Skip to content

fix: unpaired-surrogate attachment names no longer break Gmail sync - #121

Open
charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix-gmail-surrogate-filenames
Open

charan-rathore wants to merge 1 commit into
CopilotKit:mainfrom
charan-rathore:fix-gmail-surrogate-filenames

Conversation

@charan-rathore

Copy link
Copy Markdown

What changed

Two places in packages/integrations/src/google.ts run encodeURIComponent on attachment names. A name with an unpaired surrogate makes it throw "URI malformed":

  1. Incoming (mapMessage): one sender's bad attachment filename breaks the whole inbox listing on every refresh.
  2. Outgoing (the GoogleClient MIME builder): a bad attachment name makes the send fail.

Both now replace unpaired surrogates with U+FFFD before encoding. I used a small local wellFormed helper rather than String.prototype.toWellFormed(), because the repo targets ES2023 where toWellFormed does not type-check (TS2550). It is the Gmail-path counterpart of #117, which fixes the truncation side in apps/server/src/files.ts; the two do not overlap. Open #97 also edits google.ts and tests/google.test.ts for different parsing issues, so a rebase may be needed if it lands first. No issue was filed.

Verification

  • tests/google.test.ts: the two new tests fail on unchanged main with "URI malformed" (25 pass, 2 fail); patched 27/27.
  • npx tsc --noEmit and npx biome check on both changed files are clean.
  • Full tests/*.test.ts: 222 pass, 4 fail. All 4 are in tests/browser.test.ts, which fails the same way on an unpatched base.

Integration limits

No live Gmail account was used; the tests exercise the mapping and MIME builder directly.

This branch has not been deployed

No deployments
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