-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Gmail "Create Draft" bug fix #18860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Gmail "Create Draft" bug fix #18860
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughThis PR updates the Gmail component with version bumps across multiple actions and sources, and refactors MailComposer usage in sendEmail and createDraft functions to call compile() during construction rather than separately after instantiation. Changes
Sequence DiagramsequenceDiagram
participant Code as Action/Source
participant MailComposer
participant Compiled as Compiled Mail
rect rgb(200, 220, 255)
Note over Code,Compiled: Old Flow
Code->>MailComposer: new MailComposer(options)
Code->>MailComposer: mail.compile()
MailComposer->>Compiled: compiled mail
Code->>Compiled: mail.build()
Compiled-->>Code: raw message
end
rect rgb(220, 240, 200)
Note over Code,Compiled: New Flow
Code->>MailComposer: new MailComposer(options).compile()
MailComposer->>Compiled: compiled mail
Code->>Compiled: mail.build()
Compiled-->>Code: raw message
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Most changes are repetitive version increments across multiple files (low effort). The functional modification in gmail.app.mjs is a straightforward method chaining refactor that preserves behavior while improving construction semantics; this is straightforward logic to verify. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings, 2 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/gmail/gmail.app.mjs (1)
525-532: Consider aligning draft encoding with email sending for consistency.There's an encoding inconsistency between
sendEmailandcreateDraft:
sendEmail(lines 484-487) converts the message to UTF-8, fixes header formatting (:\r\nand:\n→:), then uses theencodeMessagehelper for URL-safe base64createDraft(line 532) usesmessage.toString("base64")directly without header fixing or URL-safe encodingWhile the current approach appears to work for drafts, aligning both methods would improve maintainability and reduce the risk of subtle encoding issues.
Apply this diff to align the encoding:
const mail = new MailComposer(options).compile(); mail.keepBcc = true; const message = await mail.build(); +// Fix headers that are separated with newlines +const messageFixed = message.toString("utf8") + .replace(/:\r\n/g, ":") + .replace(/:\n/g, ":"); +const rawMessage = this.encodeMessage(messageFixed); try { const response = await this._client().users.drafts.create({ userId: constants.USER_ID, requestBody: { message: { threadId: threadId, - raw: message.toString("base64"), + raw: rawMessage, }, }, });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
components/gmail/actions/add-label-to-email/add-label-to-email.mjs(1 hunks)components/gmail/actions/approve-workflow/approve-workflow.mjs(1 hunks)components/gmail/actions/archive-email/archive-email.mjs(1 hunks)components/gmail/actions/create-draft/create-draft.mjs(1 hunks)components/gmail/actions/create-label/create-label.mjs(1 hunks)components/gmail/actions/delete-email/delete-email.mjs(1 hunks)components/gmail/actions/download-attachment/download-attachment.mjs(1 hunks)components/gmail/actions/find-email/find-email.mjs(1 hunks)components/gmail/actions/get-send-as-alias/get-send-as-alias.mjs(1 hunks)components/gmail/actions/list-labels/list-labels.mjs(1 hunks)components/gmail/actions/list-send-as-aliases/list-send-as-aliases.mjs(1 hunks)components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs(1 hunks)components/gmail/actions/send-email/send-email.mjs(1 hunks)components/gmail/actions/update-org-signature/update-org-signature.mjs(1 hunks)components/gmail/actions/update-primary-signature/update-primary-signature.mjs(1 hunks)components/gmail/gmail.app.mjs(1 hunks)components/gmail/package.json(1 hunks)components/gmail/sources/new-attachment-received/new-attachment-received.mjs(1 hunks)components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs(1 hunks)components/gmail/sources/new-email-received/new-email-received.mjs(1 hunks)components/gmail/sources/new-labeled-email/new-labeled-email.mjs(1 hunks)components/gmail/sources/new-sent-email/new-sent-email.mjs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
🔇 Additional comments (22)
components/gmail/package.json (1)
3-3: LGTM: Package version bump is appropriate.The version bump from 1.3.3 to 1.3.4 follows semantic versioning for a patch release containing the BCC bug fix.
components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs (1)
9-9: LGTM: Version bump is consistent with package release.components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs (1)
7-7: LGTM: Version bump is consistent with package release.components/gmail/actions/download-attachment/download-attachment.mjs (1)
10-10: LGTM: Version bump is consistent with package release.components/gmail/actions/get-send-as-alias/get-send-as-alias.mjs (1)
8-8: LGTM: Version bump is consistent with package release.components/gmail/actions/send-email/send-email.mjs (1)
9-9: LGTM: Version bump is consistent with package release.components/gmail/sources/new-sent-email/new-sent-email.mjs (1)
9-9: LGTM: Version bump is consistent with package release.components/gmail/actions/delete-email/delete-email.mjs (1)
8-8: LGTM: Version bump is consistent with package release.components/gmail/actions/update-primary-signature/update-primary-signature.mjs (1)
7-7: Version bump only — OK.No behavioral changes; safe to ship.
components/gmail/actions/add-label-to-email/add-label-to-email.mjs (1)
7-7: Version bump only — OK.No logic changes in this action.
components/gmail/actions/create-label/create-label.mjs (1)
9-9: Version bump only — OK.No functional changes detected.
components/gmail/actions/list-labels/list-labels.mjs (1)
7-7: Version bump only — OK.No runtime impact here.
components/gmail/actions/find-email/find-email.mjs (1)
8-8: Version bump approved — BCC fix verified.Verification confirms BCC is properly integrated into Create Draft: prop definition in create-draft.mjs (line 30), passed through gmail.app.mjs (line 311), MailComposer keepBcc flag set correctly (line 524), and message with headers sent to Gmail API via raw field (line 532). Metadata version change in find-email.mjs unrelated to this feature.
components/gmail/actions/list-send-as-aliases/list-send-as-aliases.mjs (1)
7-7: LGTM! Standard version bump.The patch version increment aligns with the PR's bug fix scope.
components/gmail/actions/archive-email/archive-email.mjs (1)
8-8: LGTM! Standard version bump.The patch version increment is appropriate for this bug fix release.
components/gmail/actions/update-org-signature/update-org-signature.mjs (1)
11-11: LGTM! Standard version bump.The patch version increment is consistent with the PR's release scope.
components/gmail/sources/new-attachment-received/new-attachment-received.mjs (1)
11-11: LGTM! Standard version bump.The patch version increment aligns with the coordinated release across Gmail components.
components/gmail/sources/new-labeled-email/new-labeled-email.mjs (1)
11-11: LGTM! Standard version bump.The patch version increment is appropriate for this coordinated release.
components/gmail/actions/approve-workflow/approve-workflow.mjs (1)
7-7: LGTM! Standard version bump.The patch version increment is consistent with the PR's bug fix release.
components/gmail/sources/new-email-received/new-email-received.mjs (1)
18-18: LGTM! Standard version bump.The patch version increment aligns with the coordinated release across all Gmail components.
components/gmail/actions/create-draft/create-draft.mjs (1)
9-9: BCC fix is properly implemented and verified.The script output confirms the implementation is correct:
createDraftmethod instantiates MailComposer with all options including BCCmail.keepBcc = trueis set to preserve BCC recipients in the compiled messagegetOptionsToSendEmailproperly passesbcc: props.bccthrough options- The pattern is consistent and applied systematically
The version bump from 0.1.8 to 0.1.9 is appropriate for this bug fix. BCC recipients will now be correctly included in created drafts.
components/gmail/gmail.app.mjs (1)
523-525: LGTM! This fix should resolve the BCC bug.The change ensures
compile()is called on the MailComposer before settingkeepBcc = trueand callingbuild(). Without the compile step, the BCC recipients and other mail options aren't properly processed, which explains why BCC wasn't working in draft creation. This now matches the working pattern used insendEmail(lines 479-482).
Resolves #18847
Summary by CodeRabbit
Chores
Refactor