Skip to content

Fix Cloudflare email sending endpoint - #144

Merged
kentcdodds merged 2 commits into
mainfrom
cursor/fix-email-service-route-9391
Apr 9, 2026
Merged

kentcdodds merged 2 commits into
mainfrom
cursor/fix-email-service-route-9391

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Apr 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • update the Cloudflare email REST client to use the documented /email/sending/send endpoint
  • align the mock Cloudflare server with the same endpoint and current success response shape
  • update focused email client tests to validate the new route and clean up local lint warnings in that test file

Testing

  • npx vitest run packages/worker/src/app/email/cloudflare-email.node.test.ts
  • npx nx run worker:typecheck
  • npx oxlint packages/worker/src/app/email/cloudflare-email.ts packages/worker/src/app/email/cloudflare-email.node.test.ts packages/mock-servers/cloudflare/src/worker.ts
  • npx oxfmt --check packages/worker/src/app/email/cloudflare-email.ts packages/worker/src/app/email/cloudflare-email.node.test.ts packages/mock-servers/cloudflare/src/worker.ts
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • Updated email service integration to align with current Cloudflare API specifications.
  • Tests

    • Updated tests for email service API integration.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c05e4ca-67e4-40e9-9a0b-fc8ee7bb958e

📥 Commits

Reviewing files that changed from the base of the PR and between d3f6f61 and b80269d.

📒 Files selected for processing (3)
  • packages/mock-servers/cloudflare/src/worker.ts
  • packages/worker/src/app/email/cloudflare-email.node.test.ts
  • packages/worker/src/app/email/cloudflare-email.ts

📝 Walkthrough

Walkthrough

The PR updates the Cloudflare email API integration by migrating the endpoint from email-service/send to email/sending/send. The response envelope structure changes from returning only a messageId to including delivery state arrays (delivered, permanent_bounces, queued). The mock server, type definitions, and tests are updated to reflect this API contract change.

Changes

Cohort / File(s) Summary
Mock Cloudflare email endpoint
packages/mock-servers/cloudflare/src/worker.ts
Updated the mock email send endpoint path and changed response payload to return an envelope with delivered, permanent_bounces, and queued arrays instead of messageId.
Cloudflare email client API
packages/worker/src/app/email/cloudflare-email.ts
Updated the email send endpoint path to the new route and extended CloudflareApiEnvelope.result type to include optional delivery state arrays.
Email integration tests
packages/worker/src/app/email/cloudflare-email.node.test.ts
Updated test expectations to match the new endpoint path and response structure; adjusted mock server cleanup and return value assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #137: Directly related—updates Cloudflare email sender and mock worker with endpoint path migration and response envelope restructuring across tests and type definitions.

Poem

🐰 Cloud to cloud, the emails fly,
From old /email-service to sending/send so spry,
With delivered arrays bouncing about,
The rabbit hops faster—no more messageId clout! 📮✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-email-service-route-9391

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds marked this pull request as ready for review April 9, 2026 22:34
@kentcdodds
kentcdodds merged commit dd721d7 into main Apr 9, 2026
14 of 16 checks passed
@kentcdodds
kentcdodds deleted the cursor/fix-email-service-route-9391 branch April 9, 2026 22:34

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit b80269d. Configure here.

): Promise<CloudflareSendResult> {
const endpoint = new URL(
`client/v4/accounts/${config.accountId}/email-service/send`,
`client/v4/accounts/${config.accountId}/email/sending/send`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Vestigial messageId extraction yields perpetually undefined id

Low Severity

After switching to the /email/sending/send endpoint, the API response no longer includes a messageId field — it returns delivered, permanent_bounces, and queued instead. Yet sendViaCloudflareApi still attempts to extract payload.result.messageId and expose it as id on CloudflareSendResult. This means id is now always undefined, making both the extraction logic (lines 125–128) and the messageId field on CloudflareApiEnvelope dead code. A future developer seeing id?: string on the return type might rely on it, not realizing it's never populated.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b80269d. Configure here.

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