Repository navigation
feat: add --dry-run to emails batch and broadcasts send - #399
Open
Abhinav-2002 wants to merge 1 commit into
Open
Abhinav-2002 wants to merge 1 commit into
Abhinav-2002 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See discussion: #398
Closes the gap noted in the README:
What changed
resend emails batch --file ./emails.json --dry-runParses and validates the JSON array, normalises
snake_casefield aliases(
scheduled_at→scheduledAt,reply_to→replyTo,topic_id→topicId),and renders any
--react-emailtemplate. Note: rendering a--react-emailtemplateuses esbuild to bundle and run the
.tsxfile, which means it executes local codeeven during a dry-run.
The command then prints:
{ "dryRun": true, "request": [ ... ] }No API key required (and it skips verifying key permissions). All existing validation (bad JSON, missing file, attachments
in batch, per-entry type checks) still runs before bail-out — you get the same
error codes as a real send. Note: passing an empty array
[]now fails withinvalid_formatto enforce non-empty batches during the dry-run, which also appliesto live runs.
resend broadcasts send <id> --dry-runEchoes back the provided broadcast ID (using the interactive picker if omitted),
then prints:
{ "dryRun": true, "request": { "id": "...", "scheduledAt": "..." } }No API key required, so the ID is not verified against the API.
scheduledAtisomitted when not set.
Output format
{ "dryRun": true, "request": ... }— identical toemails send --dry-runandbroadcasts create --dry-run.Testing
Automated (8 new tests, 0 regressions):
emails batch --dry-run:[]properly errors withinvalid_format--react-emailrenders intorequest[n].htmlwithout sendingbroadcasts send --dry-run:scheduledAtappears inrequestwhen--scheduled-atis set; absent when notPre-existing failures on
table.test.ts/spinner.test.ts(Windows terminalencoding: ASCII fallback
+vs Unicode┌,vvs✔) are unrelated to thischange — they fail on clean
maintoo.Manual:
Note on AI assistance
I used an AI coding assistant (Antigravity) to help write this. I read every changed
line, ran the full test suite, and verified all the manual behaviour above myself.
The design decisions (where to bail, what to output, how to handle react-email) are
ones I can explain.
Summary by cubic
Adds
--dry-runtoemails batchandbroadcasts sendso complex payloads can be validated and inspected before a high-impact send.{ "dryRun": true, "request": ... }without calling the API, matchingemails sendandbroadcasts create, and skips the API key and permission check.--react-emailtemplates are rendered during dry-run, which executes the local.tsxcode.invalid_formatduring dry-run, and this also applies to live sends.broadcasts send --dry-runechoes the given ID (or prompts for it interactively) along with anyscheduledAt.Written for commit f3630d6. Summary will update on new commits.