fix(miniflare): local send_email accepts more than 50 recipients
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Read packages/miniflare/src/workers/email/send_email.worker.ts, especially validateMessageBuilder and the message recording path cited in the report. Compare the local validation with the Workers API's 50-recipient limit, then run the supplied reproduction against a local Wrangler session. Done means 1 and 50 recipients still succeed, 51 rejects, and Local Explorer records only the successful sends.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
Linux x86_64, Node.js 26.12.0, npm-published Wrangler 4.168.0 with Miniflare 5.20261123.1-beta and workerd 1.20261123.1. Source inspected on current main.
Please provide a link to a minimal reproduction
The complete reproduction is inline under Steps to reproduce.
Describe the Bug
Summary
A structured send through an unrestricted send_email binding in local Wrangler succeeds and writes a Local Explorer record for 51 recipients across to, cc, and bcc. This lets local integration tests accept a request the documented Workers API rejects.
Steps to reproduce
- Save the Worker and configuration below in a fresh directory, then start Wrangler in local mode:
npx [email protected] dev --local --ip 127.0.0.1 --port 0
Save this configuration as wrangler.json.
Reproduction script: wrangler.json
{"name":"email-recipient-count","main":"worker.mjs","compatibility_date":"2026-11-25","send_email":[{"name":"EMAIL"}]}
Save this Worker as worker.mjs. It exercises the binding from a local HTTP handler and returns either the message ID or the binding error.
Reproduction script: worker.mjs
export default {
async fetch(request, env) {
const { to, cc, bcc } = await request.json();
try {
const sent = await env.EMAIL.send({
from: "[email protected]", to, cc, bcc,
subject: "Recipient count probe", text: "Local simulation",
});
return Response.json(sent);
} catch (error) {
return Response.json({ code: error.code, message: error.message }, { status: 400 });
}
},
};
- Save the probe below as
reproduce.mjsand pass it the loopback URL from Wrangler'sReady online, replacingPORTwith the printed port. It exercises 1, 50, and 51 distinct placeholder addresses, reports the handler status, and verifies any returned message ID and recipient count against the Local Explorer capture. It requires Node.js and a running local development session.
node reproduce.mjs http://127.0.0.1:PORT
Reproduction script: reproduce.mjs
import assert from "node:assert/strict";
const base = new URL(process.argv[2]);
assert.equal(base.hostname, "127.0.0.1");
const addresses = (prefix, count) =>
Array.from({ length: count }, (_, index) => `${prefix}${index}@example.com`);
for (const [expected, to, cc, bcc] of [
[1, addresses("to", 1), [], []],
[50, addresses("to", 20), addresses("cc", 20), addresses("bcc", 10)],
[51, addresses("to", 21), addresses("cc", 20), addresses("bcc", 10)],
]) {
const response = await fetch(base, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ to, cc, bcc }),
});
const result = await response.json();
if (!response.ok) {
console.log(expected, response.status, result.code ?? result.message);
continue;
}
const lookup = new URL("/cdn-cgi/local/explorer/api/local/email/sending", base);
lookup.searchParams.set("email_id", result.messageId);
const record = await fetch(lookup);
assert.equal(record.status, 200);
const { result: stored } = await record.json();
assert.equal(stored.messageId, result.messageId);
const count = (stored.to?.length ?? 0) + (stored.cc?.length ?? 0) + (stored.bcc?.length ?? 0);
assert.equal(count, expected);
console.log(expected, response.status, "stored recipients", count);
}
Expected behavior
The structured Workers API limits the sum of to, cc, and bcc to 50 and documents E_TOO_MANY_RECIPIENTS above that limit. A local test at 51 should observe the validation failure before it gets a successful send or a captured message. The local simulator guide does not list a recipient-count exception.
Actual behavior
The local handler returned a message ID at 51, and Local Explorer returned a record with the same ID and all 51 addresses. The 1- and 50-recipient controls also succeeded. This was a loopback-only test with no remote binding or delivery.
1 200 stored recipients 1
50 200 stored recipients 50
51 200 stored recipients 51
Evidence
- Expected source: Email Sending Workers API, including
E_TOO_MANY_RECIPIENTSunder Error codes, and the local sending guide. - Failure source: The local probe and Local Explorer capture above. The current default-branch source listed below validates configured sender and recipient restrictions in
validateMessageBuilderand then records the message without comparing the combined recipient count to 50. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Miniflare's overview invites reports for undocumented differences from the deployed environment. Production error behavior here is from the published contract.
Restoration check
Run the probe in a fresh local session. The 1- and 50-recipient controls still return IDs and the 51-recipient case rejects with the recipient-limit signal. Then list sent messages at /cdn-cgi/local/explorer/api/local/email/sending in that session and verify that only the two controls were captured.
References
- https://github.com/cloudflare/workers-sdk/issues/16789 — covers local failures when
tois omitted and the lower bound of one recipient. - https://github.com/cloudflare/workers-sdk/pull/16844 — the proposed patch checks the lower bound. The 51-recipient case would still pass that check.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: Local integration tests that count on the binding to reject an oversized recipient list can pass incorrectly. The effect is confined to local simulation of this boundary and does not establish any live sending failure.
- Workaround status: unverified
- Workaround basis: A remote binding should expose the documented service-side validation, but the probe used only the local simulator and did not verify that route.
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
cloudflare/workers-sdk#17165 · 1 comment ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days