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 |
Silthus
force-pushed
the
feat/email-send-attachments
branch
from
October 22, 2026 05:52
9d7a267 to
cfb822c
Compare
This was referenced Oct 22, 2026
Closed
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-attachments
branch
from
October 23, 2026 17:25
cfb822c to
6095d91
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-attachments
branch
from
October 23, 2026 21:24
6095d91 to
320f9a6
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A keyed retry that listed the same headers in another order changed the idempotency fingerprint, so it got a 422 instead of a replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unknown-field check moves beside the other send field rules, so the tag serializer refuses an unknown key by name as the root body does. 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>
A code send can attach up to 10 files, 512KB in total: base64 content, a filename, an optional content type and an optional content id to show the file inline. The send route refuses blocked file types, paths and line breaks in names, and unsafe MIME parameters, without repeating the content. The worker checks the attachments again, sends them through SES as one raw MIME message that keeps PostHog's tracking and unsubscribe headers, and attaches them in maildev. Lifecycle snapshots list each file without its content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nodemailer read a header map with `key` and `value` names as one header, so a send with attachments and headers by those names went out with a malformed header and without PostHog's tracking and Auto-Submitted headers. Pass the prepared headers as a list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refused attachment answered with the why of a field PostHog doesn't know. It now says what attachments PostHog takes. The rendered send's expected payload also carries the default sender flag the code form added. 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 file named `.exe` has no suffix to the path parser, so it passed the blocked file type check. The extension is now the text after the last dot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An attachment with `contentType` or `cid` got a 202 and went out without them. Attachments now refuse an unknown key by name, as tags do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ters The email provider takes at most 78 characters for each, so a longer one got a 202 and then failed at send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lifecycle snapshot lists attachments without their content, and a rerun restored that send as is, so its lifecycle row threw and failed the whole page. The snapshot now marks the omission, and the rerun skips that row with a warning, as it does for a sensitive email. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t caps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/email-send-attachments
branch
from
October 24, 2026 17:28
320f9a6 to
b41402a
Compare
This was referenced Oct 24, 2026
Closed
13 of 16 tasks
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
Stacked on #121851 (cc, bcc, headers and tags), on #121272 and its stack. This fork PR targets
master, so the diff here includes the layers below. This layer alone:feat/email-send-fields...feat/email-send-attachments.Impact
Pays into Grow Workflows through billed
workflows_emailsactions from orgs that send by code (not measured yet: needs send attribution, #120628, merged and an insight of code sends per org). In scope: Messaging, email API sends. Expected move: small, up. Run cost: SES's attachment charge per GB sent, small at a 512 KB cap. The same queue and worker otherwise.Merge Danger
Warning
🟡 Merge risk: medium · two-way door (merge-risk rubric)
Attachmentslist on its simple message. A wrong mapping would change a file's name, type or inline placement.workflows-transactional-email-apiwith no SDK sending attachments yet.202, as a rollback after the flag turns on would.Changes
What a caller can now do
attachments: up to 10 files, 512 KB in total after decoding. Each hasfilename, base64content, an optionalcontent_typeand an optionalcontent_id.content_idshows the file inline, where the HTML references it ascid:<content_id>.template.idrefusesattachments, like the fields of the slice below..exe, also as the whole name), a filename with a path or line break, acontent_typethat is not a MIME type, and acontent_idwith<or>. No error repeats the content.content_typeandcontent_idtake at most 78 characters, the SES limit, so a longer value answers400instead of failing at SES after the202.contentType, answers400 invalid_requestonattachments. Before, the route dropped it, and an invite could lose itsmethod=REQUEST.whythat says what attachments PostHog takes.Idempotency-Keywith another attachment answers422 idempotency_key_reused.How it works
send.attachments.Content.Simple.Attachments. A file with acontent_idgoes inline, any other as an attachment.helpers/raw-mime.tsare gone.attachments_omitted.attachments_omittedwith a warning, because it can't rebuild the send. The other rows of the page still rerun.Why the 512 KB cap: the content rides inside the queued workflow run, through the workflow queue and then the email queue, so it counts against the queue's message size. SES itself takes up to 40 MB.
Not in this PR: the SDK parameter (lanes Silthus/posthog#536 and Silthus/posthog#537).
How did you test this code?
Test seams:
EmailServiceagainst a faked SES client, for the SES attachments.state.sendto the delivered file.Test rationale: what each new test catches:
422 idempotency_key_reusedfor a key reused with another attachment.whysays what attachments PostHog takes.Content.Simple.Attachments: the invite as an attachment with its type, and the logo inline by its content id.state.sendto the email step removed.{ filename, contentType, size }, drops the content and carriesattachments_omitted.content_typeorcontent_idand takes 78, refuses a file named.exe, and refuses an unknown attachment key.Each new test failed without its production change. Local gate at the stack top
987b927630e, which holds this head unchanged, all green: pytest 1764, CDP jest 3690 (1 skipped), cdp-api serial 288, MCP 5035, repo-wide mypy, nodejstsc, and the rest of the gate. The pre-push preflight ran in strict mode with 0 failures.Live run at
987b927630e(Django, cdp-api and the email worker on a migrated clone of the local test database, delivering to maildev), case 01: a code send with cccopy@example.comandinvite.ics(text/calendar; method=REQUEST) answered202. Maildev got one email tojane@example.comwith the cc and the attachmentinvite.icsastext/calendar. Maildev receives through nodemailer, not SES, so the live run does not reach the SES message. TheEmailServicetest covers its attachments.Earlier live run on
9d7a26704b5, before the review fix and before native SES attachments: inline image and refusalsinvite.ics(text/calendar; method=REQUEST) and an inlinelogo.png(content_id: logo)202invite.icsastext/calendar; method=REQUEST; name=invite.ics, and the logo asContent-ID: <logo>setup.exe400attr: attachments__0__filename, "Mailbox providers block.exefiles. Send a link to the file instead."400attr: attachments, "Attachments can hold 512KB in total. Send a link to larger files."Cross-version (base
6a82b47b1b2, headb41402aca63, real Django body, cdp-api route, workers and result store in each tree):state.send.202; the invite arrives without its.ics.attachments_omittedand sends again without the files, or a worker from this head fails the step.Not checked: real SES. A sandbox SES account was not available to this lane, so delivery of SES attachments, open and click tracking on a send with attachments, and how mail clients render the invite, are unproven. The queue size of a full 512 KB send is unverified. The base-built cross-version values are kept as fixtures in proof storage, not committed as tests. Prod shape: gap, accepted until read-only production access arrives on 2026-11-02.
Release status
Docs update
None. No doc under
docs/covers the send route.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5 (
claude-opus-5-5)spike/email-attachments. The design pass replaced the spike's raw message with native SES attachments./tdd,/improving-drf-endpoints,/writing-tests,/writing-pr-descriptions,impact,merge-risk..agents/security.mdwas read before the attachment handling.keyandvalueturned the raw message's header map into one malformed header.Content.Simple.Attachments, over a raw MIME message, so every send keeps one SES message shape. Names that end in a dot or a space get the extension check too.content_typeandcontent_id, and a file named only.exe. Round 2 found nothing to fix. The rebase check in final read 3 found nothing.🤖 Generated with Claude Code