Repository navigation
Conversation
This was referenced Oct 22, 2026
Silthus
force-pushed
the
feat/node-emails-get
branch
2 times, most recently
from
October 22, 2026 06:25
2aa98af to
577d2c8
Compare
6 of 23 tasks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es and comments 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>
The upload after `template_outdated` now sets `if_not_superseded`. When a newer deploy replaced the file's content between the send and the upload, PostHog changes nothing and the one resend returns the `template_superseded` warning. `uploadTemplate` still publishes replaced content, so it stays the rollback path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…plate file An upload of a template file now sends source.repository, source.path and source.ref without configuration. Each part comes from the explicit source option, then from GitHub Actions, GitLab CI, Vercel or Railway variables, then from the nearest git checkout above the file. The checkout is read as files, without running git, and credentials in a remote URL never leave the process. Detection never fails a send. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ments Source detection read any file named like a git file, so a pipe in a .git directory could hang a send. It now reads only regular files up to 4 MiB. A Vercel provider named like an object property, such as "constructor", no longer throws, and a quoted origin URL followed by a comment is read the way git reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
posthog.emails.send now takes the flat template form of the shared SDK contract: templateId with templateData, posted to the template send route. Every send carries an Idempotency-Key, a UUID v4 unless the caller gives one, and retries network errors, an in-flight key, throttling and 503 with the same key. A monthly quota is never retried. Errors carry Resend's names, why and fix. New client options appHost, maxRetries and migratedFrom. The secret key only goes to the app host: derived for PostHog Cloud, required for any other host. The unreleased template field, templateFile() and uploadTemplate() go away. The content hash stays for local templates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…refuses A send to a workflow that isn't active answers 400 transactional_email_paused, a validation_error. The idempotency key docs now say a replay survives a paused workflow or a changed default sender, and still refuses a deleted or changed template or a project with no default sender (PostHog/posthog#120921). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A send with options that are not an object returns invalid_form instead of throwing. - A non-string idempotencyKey returns invalid_idempotency_key. - A maxRetries that is not a whole number from 0 falls back to the client option, then to 2, so NaN or Infinity can't retry forever. - A queued 202 whose body breaks off while it is read is a network error, so the send retries with the same key and returns the first id. - A network error keeps its cause in the message. - The secretKey docs say to turn off local evaluation for a key that can't read feature flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 5 tasks
Silthus
force-pushed
the
feat/node-emails-get
branch
from
October 23, 2026 14:32
577d2c8 to
97b03b0
Compare
…fused connection's cause - A send with an option posthog-node doesn't take, such as Resend's scheduledAt, returns invalid_form on that field instead of sending without it. - A refused connection to a host with two addresses keeps both causes in the network error message. - Core parses a JSON answer with trySafe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/node-emails-get
branch
from
October 23, 2026 14:53
97b03b0 to
1aab284
Compare
A send after shutdown(), or while it drains, returns client_closed, named application_error, before any request, as the shared contract's 2026-10-24 entry asks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y hash posthog.emails.send takes the code form of the shared SDK contract: templateKey, subject, html and/or text, with optional from, replyTo and captureEngagement. The types refuse a send that mixes the two forms. Without templateData the content is rendered and goes to the send route as is, never uploaded. With templateData it is a local template: the SDK sends its content hash, and on 409 template_outdated uploads it by key with if_code_managed and sends once more with the same idempotency key. An upload refused because the key was edited in PostHog returns its error and is never retried. Template sends by id move to the send route as template.id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A local template send read its options after hashing the content, so a caller that changed the same options object before the send finished sent to the new recipient. 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>
…d's data - A template send with from, replyTo, subject, html or text returns invalid_form on that field, instead of sending without it. - A code send without a subject, or without html or text, returns invalid_form before any request. - A local template send copies its request body before it hashes the content, so a caller that changes templateData during the send changes nothing. - The round-trip tests expect a fixed content hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The code form of emails.send takes the fields the contract added on 2026-10-22. Addresses become lists, attachment bytes become Base64 once per send, and a Resend attachment path returns invalid_attachment before any request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PostHog server that doesn't take cc, bcc, headers, tags or attachments yet answers 400 invalid_request with the field in attr, so the send fails as a validation_error on that field instead of going out without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e send A template send with one of these fields returns invalid_form on that field, instead of sending without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
posthog.emails.get(id) reads GET messaging/emails/{id}/ on the app host
with the secret key and returns { id, status, createdAt, statusAt,
reason? } or the error. It never retries: a new email answers not_found
for its first seconds, so the caller reads again later.
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>
…s scope - emails.get with an id that has a lone surrogate returns invalid_message_id instead of throwing. - Without a secret key, emails.get names the hog_flow:read scope. - The EmailError code docs list invalid_message_id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
force-pushed
the
feat/node-emails-get
branch
from
October 24, 2026 12:43
1aab284 to
fc5dc17
Compare
This was referenced Oct 24, 2026
Draft
This was referenced Oct 25, 2026
Silthus
added a commit
to Silthus/posthog-js
that referenced
this pull request
Oct 25, 2026
Moves PostHog#5372 (feat/node-emails-get at fc5dc17) onto the code fields slice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
added a commit
to Silthus/posthog-js
that referenced
this pull request
Oct 25, 2026
Moves PostHog#5372 (feat/node-emails-get at fc5dc17) onto the code fields slice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
added a commit
to Silthus/posthog-js
that referenced
this pull request
Oct 25, 2026
Moves PostHog#5372 (feat/node-emails-get at fc5dc17) onto the code fields slice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus
added a commit
to Silthus/posthog-js
that referenced
this pull request
Oct 25, 2026
Moves PostHog#5372 (feat/node-emails-get at fc5dc17) onto the code fields slice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
After a send, an app cannot read back what happened to the email, so it cannot show "sent" or "bounced" next to a user.
This PR adds
posthog.emails.get(id)from the shared SDK contract PostHog/posthog#120921, "Read":Slice 11 of strand Silthus/posthog#536, map Silthus/posthog#461.
Stacked on #5373 (code-form fields), on #5371 (slice 10), on #5312. This fork PR targets
main, so its diff includes all three. This layer alone:feat/node-emails-code-fields...feat/node-emails-get.Server dependency, not built yet:
GET /api/projects/@current/messaging/emails/{message_id}/is slice 08 of the send-api strand (the spec's pin). This PR is built against the contract at the HTTP seam.Impact
Pays into Grow Workflows through billed
workflows_emailsfrom API sends (not measured yet: the send attribution of PostHog/posthog#120628 plus its insight). In scope: Messaging, email. Expected move: small, up: the status read lets a Resend site that shows delivery state move. Run cost: n/a.Merge Danger
Caution
🔴 Merge risk: high · one-way door (merge-risk rubric)
posthog.emails.get()to the public API. Once released, the status names and fields are a contract callers branch on.Changes
emails.get(id)readsGET messaging/emails/{id}/on the app host with the secret key, the id as one encoded path segment.{ data: { id, status, createdAt, statusAt, reason? }, error: null }or{ data: null, error }, with the same error names assend.reasonis left out when PostHog gives none.404,429,503or a network error. A new email answers404 not_foundfor its first seconds, and the JSDoc says so.statusis not Resend'slast_event.missing_secret_key(naming thehog_flow:readscope),missing_app_host,client_disabled,client_closedaftershutdown(), assenddoes, andinvalid_message_idfor an empty id or one that can't be encoded into a URL, namedvalidation_erroras the contract's local checks are.Parity with posthog-python
id,status,created_at,status_at,reason?id,status,createdAt,statusAt,reason?statusvaluesqueued,waiting,unknown,skipped,failed,sent,delivered,bounced,complainedEvidence
emailsnamespace on a real client,fetchmocked byFakeEmailsApi, which now answers the status route (emails.spec.ts,describe('get')).Authorization,User-AgentandX-PostHog-Migrated-From; the field mapping with and withoutreason; one request and the error for404,503,429, a network failure and an answer without a status; the refusals before any request, with the scope in the missing-key message and a lone-surrogate id; an id with/and?read as one path segment.get, then green. The review fix's 2 cases failed before it, then green.fc5dc171(on the leased compute box): nodevitest(1350 passed), the edge build tests (1350 passed),tscfor the build and the type tests,oxlint,oxfmt, build andgenerate-references; corevitest.getuntilsent): gap. The read route is slice 08, not built yet.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Michael (@Silthus) decided the read path in the spec. Built by Claude Code (Claude Opus 5.5) test-first, as one build lane of the map.
GET messaging/emails/{message_id}/,hog_flow:readstatusvalue from a newer serverEmailStatusgetaftershutdown()client_closed, asgetalready refuses withclient_disabled; the contract names only a sendOpen: none.
Involvement: spec decisions by Michael; one strand review by GPT-6.1 Sol over #5312, #5371 and #5372 (2 findings: 1 fixed in #5371, 1 rejected as behavior that predates this strand) and a final read of the fix with no findings; a second final read after the restack on #5373 and the
invalid_message_idname fix, with no findings; a QA swarm over the restacked stack in two rounds (Review lane GPT-6.1 Sol with seven lenses, Fresh-eyes lane Claude Opus 5.5) with its fix in this PR; no live run yet.🤖 Generated with Claude Code