Skip to content

fix: avoid mutating payloads in emails, broadcasts, and templates#862

Open
Shubhdeep12 wants to merge 3 commits intoresend:canaryfrom
Shubhdeep12:fix/payload-mutation
Open

fix: avoid mutating payloads in emails, broadcasts, and templates#862
Shubhdeep12 wants to merge 3 commits intoresend:canaryfrom
Shubhdeep12:fix/payload-mutation

Conversation

@Shubhdeep12
Copy link
Contributor

@Shubhdeep12 Shubhdeep12 commented Mar 2, 2026

  • used cloned bodies / local html variables instead of writing payload.html when react is provided.
  • added a test

Summary by cubic

Stop mutating request payloads in emails, broadcasts, and templates when rendering React to HTML. This prevents side effects and keeps input objects unchanged.

  • Bug Fixes
    • Use local html variables/body copies instead of writing to payload.html in emails.create, broadcasts.create/update, and templates.create.
    • Added tests to verify payload immutability for emails, broadcasts, and templates. No API changes.

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

@Shubhdeep12 Shubhdeep12 requested a review from a team as a code owner March 2, 2026 15:52
@Shubhdeep12 Shubhdeep12 requested a review from rehanvdm March 2, 2026 15:52
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/resend@862

commit: 1f7f772

Copy link
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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@gabrielmfern gabrielmfern changed the title fix: to avoid mutating payloads in emails, broadcasts, and templates fix: avoid mutating payloads in emails, broadcasts, and templates Mar 2, 2026
expect(mockRenderAsync).toHaveBeenCalledWith(mockReactComponent);
});

it('does not mutate payload when using React component', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

can you also add tests to email.ts and @broadcasts.ts for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added. thanks for review.

@rehanvdm rehanvdm removed their request for review March 5, 2026 17:16
@Shubhdeep12 Shubhdeep12 requested a review from gabrielmfern March 6, 2026 01:39
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.

2 participants