fix(miniflare): capture decoded bytes for base64 email attachments
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Inizia da packages/miniflare/src/workers/email/send_email.worker.ts, dove l’issue dice che i metadati e i file degli allegati usano il valore del contenuto originale; verifica come viene rappresentato e decodificato lì il contenuto base64. Poi leggi il test degli allegati in packages/miniflare/test/plugins/email/index.spec.ts, che attualmente si aspetta una stringa letterale. Il lavoro è completato quando un allegato base64 valido viene acquisito come byte decodificati con la dimensione decodificata e il comportamento binario esistente continua a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What versions & operating system are you using?
Wrangler 4.168.0 from the npm latest tag, with Miniflare 5.20261123.1-beta and workerd 1.20261123.1. Node.js 26.12.0 on Linux x86_64. Source inspected at workers-sdk main commit 927f070ee0589a2567a76f2000dcff60b1b3d2eb. Only the local simulator was exercised.
Please provide a link to a minimal reproduction
Inline two-file reproduction.
Describe the Bug
Summary
In local wrangler dev, a structured Email Sending message with a base64 attachment succeeds, but the captured file contains the base64 characters. Local Explorer also reports the encoded length as the attachment size. The equivalent binary input produces the expected file and size, so these local inspection results depend on how the same attachment bytes were passed to the binding.
Steps to reproduce
- In an empty directory, save the two files below as
wrangler.jsoncandworker.mjs. The configuration starts a local-only email binding. The Worker sends an attachment to a reserved example address with base64 content on/base64and equivalent binary content on/binary. Both requests return the simulated send result. - Install and run Wrangler using these commands. Use the loopback URL printed next to
Ready onfor$BASE_URL.
npm install --save-exact [email protected]
npx wrangler dev --local --ip 127.0.0.1 --port 0
- Request
/base64and/binaryat that URL. Each response supplies amessageId. Remove the angle brackets to find its matching<message-id>-1.binbelow.wrangler/tmp/email/, then examine the file withod -An -tx1. File capture runs asynchronously, so wait for the file to appear. - Request
$BASE_URL/cdn-cgi/local/explorer/api/local/email/sending?worker=attachment-checkand compareresult[].attachments[0].sizefor the two subjects.
Reproduction script: wrangler.jsonc
{
"name": "attachment-check",
"main": "worker.mjs",
"compatibility_date": "2026-11-25",
"send_metrics": false,
"send_email": [
{
"name": "EMAIL"
}
]
}
Reproduction script: worker.mjs
export default {
async fetch(request, env) {
const mode = new URL(request.url).pathname;
const binary = Uint8Array.of(0, 1, 2, 255);
const content = mode === "/base64" ? "AAEC/w==" : binary;
return Response.json(await env.EMAIL.send({
from: "[email protected]",
to: "[email protected]",
subject: "Attachment check " + mode,
text: "See attached.",
attachments: [{
content,
filename: "fixture.bin",
type: "application/octet-stream",
disposition: "attachment",
}],
}));
},
};
Expected behavior
The local capture for the documented base64 attachment should produce an inspectable .bin file with the four decoded bytes and report 4 bytes in Local Explorer. The equivalent binary request serves as a control on the tested release.
Actual behavior
Both endpoints returned HTTP 200 with a message ID. The base64 file contained the eight ASCII characters of AAEC/w==, and Local Explorer reported size 8. The binary control captured the expected four bytes, and Local Explorer reported size 4.
/base64 41 41 45 43 2f 77 3d 3d size=8
/binary 00 01 02 ff size=4
Evidence
- Expected source: The Workers binding interface describes
contentas a base64 string or binary. It warns that binary input is unsupported in local development. The binary request still worked as a control in this Wrangler run. The repository's Email Worker fixture under What to Expect describes opening captured files to inspect their contents and says attachments retain their original extensions. - Failure source: The local Wrangler run above. On the inspected default branch,
packages/miniflare/src/workers/email/send_email.worker.tspasses the original value tocontentByteLengthandstoreTempFilewhen populating the capture metadata and file, respectively. The existing attachment test inpackages/miniflare/test/plugins/email/index.spec.tsexpects the literalbase64contentstring, a 13-character input that is not valid base64. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Restoration check
Repeat both local requests and compare their captured files and Local Explorer rows. Each request should still return a message ID. Each file should contain 00 01 02 ff, and each row should report size 4.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: Developers inspecting locally captured base64 attachments get different file bytes and attachment sizes from equivalent binary inputs, which can produce misleading local verification of attachment data.
- Workaround status: available
- Workaround basis: Decode the captured file with
base64 -d < capture.bin > decoded.binand inspect the decoded file and its byte count. This produced the same four bytes as the binary control without changing the Worker.
- Lingua principale
- TypeScript
- Stelle
- 4.7k
- Fork
- 1.7k
- Merge medio
- 1g 23h
- PR unite (30g)
- 290
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cloudflare/workers-sdk
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
cloudflare/workers-sdk#17189 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cloudflare/workers-sdk#17187 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
cloudflare/workers-sdk#17175 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
cloudflare/workers-sdk#17165 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cloudflare/workers-sdk#17159 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cloudflare/workers-sdk
Issue simili
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsApertabug triage:owned
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
directus/directus#28558 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
review: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
1lck/Lithe-IDEA#2432 ·
I maintainer di solito rispondono entro 1 giorno
-
AWS Lambda Waiting for: Product Owner
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
getsentry/sentry-javascript#26910 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno