Skip to content

feat(messaging): set hard_bounced_at from the suppression writers - #125374

Merged
trunk-io[bot] merged 2 commits into
posthog/transactional-email-hard-bounce-onlyfrom
posthog/messaging-suppression-hard-bounce-writers
Oct 29, 2026
Merged

trunk-io[bot] merged 2 commits into
posthog/transactional-email-hard-bounce-onlyfrom
posthog/messaging-suppression-hard-bounce-writers

Conversation

@meikelmosby

@meikelmosby meikelmosby commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • fix(messaging): send transactional workflow email unless the address hard-bounced #124638 decides whether an address blocks transactional email from hard_bounced_at, and falls back to the row's reason text for rows written before that column existed.
  • A Customer.io import is the only writer that still depends on that fallback. It creates BOUNCE rows for the bounces and invalid-emails lists and leaves the column null, so every new import adds another row the fallback has to carry.
  • Reason text is fragile evidence. A later complaint or a run of soft bounces replaces it.
  • Removing a suppression resets the row but leaves hard_bounced_at set, so a re-enabled address would still be treated as dead.
  • This is the top layer of a stack. Raised in a Slack thread (link below).

Changes

How did you test this code?

  • Ran products/messaging/backend/ locally: 453 passed.

Test rationale:

  • A new case in test_provider_imports.py asserts that a Customer.io bounce import sets hard_bounced_at and a spam report does not. It catches an importer that marks a working address as dead, which would drop its invoices and password resets.
  • The existing remove-suppression test now also asserts that removal clears hard_bounced_at and a legacy hard-bounce reason. A removal that keeps the mark would block transactional email to an address a user deliberately re-enabled.

Release status

  • No feature flag controls this change

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Claude Opus 5


Created with PostHog from a Slack thread

🤖 Generated with Claude Code

@meikelmosby
meikelmosby changed the base branch from posthog/messaging-suppression-hard-bounced-at to posthog/transactional-email-hard-bounce-only October 29, 2026 10:49
@meikelmosby
meikelmosby added this pull request to stack #124639 October 29, 2026 10:49
The Customer.io importer marks bounced and invalid addresses as hard-bounced,
so the send path stops relying on their reason text. Removing a suppression
clears the mark, so a re-enabled address starts clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane, mixes lanes

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

This PR changes Python or frontend code (products/messaging/backend/migrations/0011_messagesuppression_hard_bounced_at.py, products/messaging/backend/migrations/max_migration.txt, products/messaging/backend/models/message_suppression.py and 4 more) and Node or Rust code (nodejs/src/cdp/services/messaging/email-suppression.service.test.ts, nodejs/src/cdp/services/messaging/email-suppression.service.ts, nodejs/src/cdp/services/messaging/email-tracking.service.test.ts and 2 more) together. In the merge queue, every Node or Rust PR behind it in the same lane then runs the Django and frontend suites too, so the cross-lane check fails. Split it, or add the cross-lane-change label if the halves must land together.

⚠️ Duplication (Python) — 2 new duplicated blocks (worst 116 tokens)

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

First copy Second copy Lines Tokens
products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/incident_io.py:17 products/warehouse_sources/backend/temporal/data_imports/sources/sendgrid/sendgrid.py:21 12 116
products/messaging/backend/models/message_suppression.py:35 products/messaging/backend/models/supabase_auth_email_config.py:12 11 75
⚠️ Duplication (TypeScript) — 1 new duplicated block (worst 71 tokens)

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

First copy Second copy Lines Tokens
products/web_analytics/frontend/pageReports/pageReportDetailLogic.ts:242 products/web_analytics/frontend/pageReports/pageReportDetailLogic.ts:256 12 71
✅ Django migration risk — migration analysis complete

We've analyzed your migrations for potential risks.

Summary: 1 Safe | 0 Needs Review | 0 Blocked

✅ Safe

Brief or no lock, backwards compatible

messaging.0011_messagesuppression_hard_bounced_at
  └─ #1 ✅ AddField
     Adding nullable field requires brief lock
     model: messagesuppression, field: hard_bounced_at

📚 How to Deploy These Changes Safely

AddField:

This operation acquires a brief lock but doesn't rewrite the table.

Deployment uses lock timeouts with automatic retries, so lock contention will cause retries rather than connection pile-up.

Last updated: 2026-10-29 12:28 UTC (cfc9abd)

The node writes treat a BOUNCE row with a legacy hard-bounce reason as hard-bounced. A removed row kept that reason, so the next soft bounce or complaint set hard_bounced_at again, and the re-enabled address later lost transactional email. Removing a suppression now clears the reason as well.

Generated-By: PostHog Desktop
Task-Id: 120fc7fd-3cc1-484a-99ee-da0e2036ca93
@parameterai

parameterai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Risk: No findings

This change marks Customer.io-imported bounce/invalid-email suppressions with hard_bounced_at (so they block transactional mail like our own hard bounces) and clears that mark plus the reason when a user removes a suppression. All writes stay team-scoped through for_team(team_id) and the mutating endpoints keep their existing project-wide hog_flow editor access check, so I found no security impact.

Sentinel reviewed cfc9abd · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team October 29, 2026 12:14
@mayteio mayteio added the cross-lane-change Allow for cross lane (i.e. django + rust) changes to merge at once label Oct 29, 2026 — with PostHog
@mayteio
mayteio marked this pull request as draft October 29, 2026 12:23
@mayteio
mayteio marked this pull request as ready for review October 29, 2026 12:24
@trunk-io

trunk-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

mayteio commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

/depot retry

@trunk-io

trunk-io Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request is queued for merge as part of 125322, which will merge 124637, 124638, 125374, 125322.

@trunk-io
trunk-io Bot merged commit 15419e0 into master Oct 29, 2026
492 of 497 checks passed
@trunk-io
trunk-io Bot deleted the posthog/messaging-suppression-hard-bounce-writers branch October 29, 2026 16:26
@trunk-io

trunk-io Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request was merged into master as part of stacked PR 125322.

@deployment-status-posthog

deployment-status-posthog Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-29 17:20 UTC Run
prod-us ✅ Deployed 2026-10-29 17:42 UTC Run
prod-eu ✅ Deployed 2026-10-29 17:47 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cross-lane-change Allow for cross lane (i.e. django + rust) changes to merge at once

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants