Campaign dispatch recheck ignores allow_unverified: recipients skipped as 'unverified' at claim time

Open Beginner friendly
#108 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
api, backend

Research direction

Read mailing/services/campaign_sender.py::_suppression_reasons, suppression.py::suppression_skip_reason, and the snapshot gate in mailing/services/campaigns.py::_annotate_snapshot_skip. Pass the campaign context into the dispatch recheck and confirm allow_unverified only bypasses the unverified reason; hard bounces, complaints, unsubscribes, and invalid email validation must remain suppressed. Add or update tests for both cases and verify an allowed unverified recipient is not skipped at claim time.

Written by the indexing model from the issue text.

Description

Evidence (production, 2026-11-11 01:32 UTC)

An API campaign queued with allow_unverified: true (recipient_list_key aishl-test-21-…, 200 recipients) finished dispatch in ~4s with status=sent and all 200 campaign_recipients status=skipped, skip_reason='unverified', zero SES message ids, zero counters. The snapshot annotation honored the flag (recipients created as pending candidates), but the worker's suppression recheck skipped every one at claim time.

Root cause

mailing/services/campaign_sender.py::_suppression_reasons calls suppression.py::suppression_skip_reason(contact, …), which returns UNVERIFIED whenever neither the contact nor its audience/client subscription has verified_at — it never sees campaign.allow_unverified. The snapshot-time annotation (mailing/services/campaigns.py::_annotate_snapshot_skip, line ~236) correctly gates the UNVERIFIED rule on if not campaign.allow_unverified, so the flag is only half-implemented: allowed at snapshot, ignored at dispatch.

Suggested fix

_suppression_reasons has the campaign in scope; pass it through and skip the UNVERIFIED branch when campaign.allow_unverified is set (mirroring the snapshot gate). Suppression for hard bounces, complaints, unsubscribes and invalid email validation should stay unconditional.

Impact

Any API client using allow_unverified campaigns (the documented partner for recipient_list_key sends — the flag is even required to be paired with a recipient list) silently sends to nobody. The AISHL website's guarded internal bulk proof depends on it; a website-side workaround (verifying contacts at upsert) shipped in AI-Shipping-Labs/website#2085 as a stopgap.

Dominant language
Python
Stars
0
Forks
0
Avg merge
26m
Merged PRs (30d)
58

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DataTalksClub/relay

All issues in DataTalksClub/relay

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.