Repository navigation
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This was referenced Oct 22, 2026
Silthus
force-pushed
the
feat/email-send-route-idempotency
branch
from
October 23, 2026 03:37
d19417f to
8f4b3a2
Compare
This was referenced Oct 23, 2026
A message template gets a code key unique per team, an owner, a source and a content hash, so code can upload and lock a template by key. Part 1 of 3 of PostHog#118924. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lates Code uploads an email template by key, which locks it against edits in PostHog. Giving a template a key adopts it. A send names the template by key or id and carries a content hash, so a stale upload is refused. Part 2 of 3 of PostHog#118924. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/email-send-route-idempotency
branch
from
October 23, 2026 17:25
8f4b3a2 to
9a2b0e1
Compare
This was referenced Oct 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/email-send-route-idempotency
branch
from
October 23, 2026 21:24
9a2b0e1 to
0398172
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The template library marks a code-managed template with its source and key, shows it read-only, and offers a release back to PostHog. Part 3 of 3 of PostHog#118924. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ield Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A queued transactional email is now recognized by its own event, and runs the trigger of its accepted version too, so a later trigger edit cannot unpin it. A step marked sensitive after the send was accepted stays sensitive, and a version whose step holds secret inputs runs live, because revisions do not store secrets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An admission refusal's detail read "Skipping send: ...", although the send was refused and never queued. The policy and the address check now state what they found, and the delivery log adds "Skipping send:". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…der changes cdp-api checks that the workflow is active after it looks up the idempotency key, and answers transactional_email_paused with why and fix. Django keeps only the check that the workflow exists. The fingerprint leaves out the project's default sender, which the caller didn't name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A worker that reloads inside the save's transaction caches the old row, so a pause did not stop new transactional sends until the cache aged out. The post_save publish now waits for commit, as the delete publish does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h fails Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/email-send-route-idempotency
branch
from
October 24, 2026 17:28
0398172 to
ba5d72e
Compare
Contributor
Author
|
Note 🤖 Claude Opus 5.5 responding on behalf of Michael Two decisions for this PR:
Slice 05 gets no PR of its own: the reserve, replay and release here use the store |
This was referenced Oct 25, 2026
This was referenced Nov 2, 2026
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.
Problem
POST /api/projects/@current/messaging/send/email/cannot retry safely. The route reads noIdempotency-Key, so a retry after a timeout can send the email twice. Contract #120921 promises the key on both send routes.Stacked on #121850, on #121272, on #121084, on #121083, on #118924. This fork PR targets
master, so the diff here includes all five. This layer alone:feat/email-send-admission-checks...feat/email-send-route-idempotency.Impact
Pays into Grow Workflows through billed
workflows_emailsactions per paying org (not measured yet as a monthly count). In scope: Messaging, email API sends. Expected move: small, up: a caller can retry a send without sending it twice, which the API needs to replace another email provider. Run cost: n/a, the key check already runs on the template route.Merge Danger
Warning
🟡 Merge risk: medium · two-way door: no migration, and a revert stops the route from sending keys (merge-risk rubric)
422.Changes
What a caller now sees
send/email/reads theIdempotency-Keyheader, on both the template form and the rendered-content form.202, with the samemessage_idandreplayed: true. No second email goes out.422 idempotency_key_reused. Another request means another recipient, other data, other rendered content, sender, reply-to or capture choice, or the other send route.409 idempotency_key_in_flight.400 transactional_email_pausedafter the key lookup.404,409or400on a retry.How it works
route: "send_email"to cdp-api. The template route (messaging_templates/{id}/send/) sends noroute.transactionalSendFingerprint: the workflow,to,distinct_idandvariables, plus the wholesendand theroutewhen either is present. A sender Django chose as the default (from.isDefault) is left out.master. A retry across the deploy still matches the key it reserved.masteralready has (scopetransactional-email). Slice 05 of the map needs no PR of its own for that reason.Mechanical:
IDEMPOTENCY_KEY_PARAMETERmoved to the shared module, so both routes document the header; the regenerated OpenAPI types and MCP tool schema.How did you test this code?
Test rationale: each case below failed before its fix and passes after it.
Test seams:
422 idempotency_key_reusedand queues once.template.key,template.id,template_key) passes the key, reports a replay, and sendsrouteonly fromsend/email/.Local gate at the stack top
987b927630e, which holds this head unchanged, all green: cdp-api serial 288, CDP jest 3690 (1 skipped), pytest 1764, MCP 5035, repo-wide mypy, nodejstsc, and the rest of the gate. The pre-push preflight ran in strict mode with 0 failures.Cross-version: owed, because the cdp-api request gains
routeand the key's fingerprint changes. Checked with this layer's base and head side by side, before the review fixes. The fixes did not touch the fingerprint, and the run did not repeat at this head:route: "send_email"route, so the key is bound as onmaster. Until cdp-api deploys, a key reused on the other route replays instead of answering422.routemaster's, so a key reserved before the deploy still matches. Old Django sends no key fromsend/email/.from.isDefaultisDefault, so the default sender stays in the fingerprint. An inactive workflow answers503instead of400. Nothing is sent.isDefault422, not a replay. The flag stays off until both sides deploy, so no such key exists.Cross-version run output
Live run at
987b927630e(Django, cdp-api and the email worker on a migrated clone of the local test database, delivering to maildev):Idempotency-Key, sent twice202with the samemessage_id; the second saysreplayed: true. Maildev held 1 email.422 idempotency_key_reused, withdocs_url. Still 1 email.Gaps:
cc,bcc,headers,tagsandattachmentsfrom #121851 and #121852 are not on this base. They live insidesend, so they join the fingerprint without a code change. feat(messaging): send cc, bcc, headers and tags with a code send #121851 and feat(messaging): send attachments with a code send #121852 add their422 idempotency_key_reusedtest rows.Release status
Docs update
None. The transactional email API docs page is written after the stack lands.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5 (
claude-opus-5-5)idempotency_key_reused, the namemasteralready answers, over the contract's earlierinvalid_idempotent_requestmaster's cdp-api already reserves, replays and releases through the shared store422Open: should a reused key with a changed
template.hashreplay or answer422? It replays today, because the fingerprint does not include the template version. Neither answer sends twice (➡️ keep the replay, and say in theIdempotency-Keyhelp that the key binds the recipient, data and send choices, not the template version).Open: the rollout decision on #121272: keep the deploy order plus the flag, or give code sends their own cdp-api path (➡️ the current plan is the deploy order plus the flag).
Review (GPT-6.1 Sol, round 1 over the whole stack, then a final read of the fixes):
422.The stack's QA swarm then reviewed this layer. Round 1 moved the workflow reload after commit and raised this grade to medium. Round 2 made that reload robust to a failed publish and fixed two comments. Final read 1 and the rebase check in final read 3 found nothing. Follow-up: the MCP tool
workflows-send-emailcannot send anIdempotency-Keyyet.workflows-transactional-email-apiflag stays off until tracking code v3 minting is on and every stack PR, this one included, has deployed on Django, cdp-api, the hogflow worker and the email worker.Involvement: strand conductor relays answered, one choice from Michael on replay scope, no grilling rounds. Reviews: GPT-6.1 Sol round 1 over the whole stack and a final read of the fixes. Stack QA swarm: design pass (GPT-6.1 Sol high); round 1 (review and team lanes GPT-6.1 Sol high, fresh eyes Claude Opus 5.5 high); round 2 on the fixes (review lane GPT-6.1 Sol high, fresh eyes Claude Opus 5.5 high); final read 1 and final read 3 over the rebase (GPT-6.1 Sol high, clean); fixers Claude Opus 5.5 high; live run at the stack top.
/tdd,/improving-drf-endpoints,/writing-tests,/writing-code-comments,/writing-pr-descriptions.send/email/.example.comdomains.🤖 Generated with Claude Code