chore: hook up provisioning_welcome Customer.io template#58820
Merged
Conversation
CUSTOMER_IO_TEMPLATE_ID_MAP was missing an entry for the "provisioning_welcome" template name used by send_provisioning_welcome (posthog/tasks/email.py:382). The Customer.io HTTP sender raised "Unknown template name", and the Celery task swallowed it via capture_exception, so the welcome email silently failed for every provisioned user. Verified the template exists in the EU workspace (transactional message id 67, "Welcome to PostHog - set your password") and that template variables match what send_provisioning_welcome passes (link, site_url, preheader, partner_name, cloud). Add a regression test that parses posthog/tasks/email.py and asserts every EmailMessage(use_http=True, template_name="X") has "X" in CUSTOMER_IO_TEMPLATE_ID_MAP, so the same silent-failure mode doesn't recur when future transactional emails are added. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
🎭 Playwright didn't run on this PR — your changes touch code that could affect E2E behavior, but Playwright is opt-in via label now to keep CI cost down. Add the Most PRs don't need this. Real regressions still get caught on master and fix-forward. |
This was referenced May 18, 2026
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog/test/test_email.py:337-340
The AST scan is scoped only to `posthog/tasks/email.py`, but `posthog/temporal/proxy_service/common.py` also contains `EmailMessage(use_http=True, template_name="proxy_provisioned", ...)` with a literal template name. If someone adds a new HTTP transactional email in that file (or any other future file in the `posthog/` tree) and forgets the map entry, the test will silently pass. Widening the scan to all `.py` files under `posthog/` catches the same silent-failure pattern everywhere.
```suggestion
import posthog.tasks.email as email_tasks
repo_root = Path(email_tasks.__file__).parent.parent
sources = list(repo_root.glob("posthog/**/*.py"))
```
Reviews (1): Last reviewed commit: "chore: hook up provisioning_welcome Cust..." | Re-trigger Greptile |
…code posthog/temporal/proxy_service/common.py and posthog/approvals/notifications.py also call EmailMessage(use_http=True, template_name=...), so a future new transactional email added anywhere under posthog/ (not just posthog/tasks/email.py) would slip past the regression assert. Walk the whole package, skip test_*.py and test/ dirs so synthetic test templates don't have to be mapped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rafaeelaudibert
approved these changes
May 20, 2026
Member
rafaeelaudibert
left a comment
There was a problem hiding this comment.
Yeah, this is good!
Feedback on the email: suggest using the MCP too.
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
The welcome email for provisioned users (sent by
send_provisioning_welcomeinposthog/tasks/email.py:382) was silently dropped in production.EmailMessage(use_http=True, template_name="provisioning_welcome", ...)routes through the Customer.io HTTP sender, which callsget_customer_io_template_id("provisioning_welcome")and raisesUnknown template namebecause that template was never added toCUSTOMER_IO_TEMPLATE_ID_MAPinposthog/email.py. The exception is caught andcapture_exception-d atviews.py:658-662, so provisioning succeeds with zero user-visible signal that the email failed.Changes
"provisioning_welcome": "67"toCUSTOMER_IO_TEMPLATE_ID_MAP..pyunderposthog/(skippingtest_*.pyandtest/dirs) viaastand asserts everyEmailMessage(use_http=True, template_name="X")has"X"in the map. Stops the same silent-failure pattern from recurring when future transactional emails are added — coversposthog/tasks/email.py,posthog/temporal/proxy_service/common.py,posthog/approvals/notifications.py, and anything new.Template 67 is Welcome to PostHog - set your password in the EU Customer.io workspace. Variables match what
send_provisioning_welcomepasses (link,site_url,preheader,partner_name,cloud).How did you test this code?
Agent author. Tests run:
pytest posthog/test/test_email.py::TestEmail::test_all_http_templates_are_registered_in_customer_io_map— passes locally.cioCLI to send a live transactional message via template 67 tomatt@posthog.comwith the exact payload shapesend_provisioning_welcomeproduces. Delivery confirmed (idROjhBwUAAZ47Xh8nfKVYBN2BYD_FVg==, statesent).Publish to changelog?
No.
🤖 Agent context
Co-authored by Claude (Opus 4.7). Surfaced in a session triaging security ticket #669 (CIMD pre-account-takeover). Three stacked PRs are planned to land:
is_email_verifiedto True on password reset (proves email ownership via the unique token from the reset link).A and B have no code dependency; both are conceptually prerequisites for C. Stacked via Graphite. Decisions made: chose an AST-parse regression test over an enumerated list of template names so the check stays correct when new transactional emails are added; placed the test in
posthog/test/test_email.pyrather thanposthog/tasks/test/test_email.pysince the assertion is aboutCUSTOMER_IO_TEMPLATE_ID_MAP(defined inposthog/email.py).