Welcome email has no delivery record and cannot be retried
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 40/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- postgresql, typescript
Hướng nghiên cứu
Start with the Stripe checkout.session.completed handler and the welcome send in lib/email/send.ts, then read the sweep pattern in bot/index.ts and claimStuckTicketForRetry in lib/db/queries/tickets.ts. Check the PUBLIC_PATHS prefix rules in auth.ts before adding any route. Done means the orgs columns exist, a failed send is retryable up to a capped number of attempts, a successful send is never repeated, and tests fail if the claim stops being atomic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Copied from DeadantCo/answerLoops#19 · originally opened by sethr07 on 2026-11-20
Copied from https://github.com/answerLoops/answerLoops/issues/45 — originally opened by
@NathanTarberton 2026-08-21
Summary
The welcome email is sent once, from the Stripe checkout.session.completed handler, and there is no record that it was attempted. If the mail provider is unavailable at that moment the send is logged and dropped. Nothing retries it and nothing surfaces it, so the org simply never gets welcomed.
The send is deliberately non-fatal — returning a non-2xx would make Stripe retry an event whose subscription is already written — so "swallow and log" is the right immediate behaviour. What's missing is the durable record that would let it be retried.
Why it can't retry today
Whether an org has already been welcomed is inferred rather than recorded: the handler treats "this org had no subscription before this event" as "this org has not been welcomed." That works for the happy path but makes a failed send unrecoverable, because after the upsert the org does have a subscription — so a retry would read the same signal and conclude the welcome was already handled.
Proposed fix
1. Record the outcome. Add welcome_email_sent_at and welcome_email_attempts to orgs. This replaces the inference with a fact and makes a failed send visibly incomplete rather than indistinguishable from a completed one.
2. Stamp it on success. The checkout handler sets welcome_email_sent_at after a successful send and continues to return 200 either way.
3. Sweep the gaps. A periodic job finds orgs with an active subscription, welcome_email_sent_at IS NULL, subscribed more than a few minutes ago, bounded to a recent window so a permanently undeliverable address is not retried indefinitely. bot/index.ts already runs two sweeps of this shape (org purge, stuck tickets) and this should follow the same structure.
4. Claim atomically before sending. Same pattern as claimStuckTicketForRetry in lib/db/queries/tickets.ts:
UPDATE orgs
SET welcome_email_attempts = welcome_email_attempts + 1
WHERE id = $1
AND welcome_email_sent_at IS NULL
AND welcome_email_attempts < $2
RETURNING id
No rows returned means another worker holds it or the attempt cap is reached. The cap is what prevents an unbounded retry loop against an address that will never accept mail.
The sweep should call a BOT_SECRET-authenticated route, mirroring /api/ingest/retry-stuck.
One thing to get right when adding it: PUBLIC_PATHS in auth.ts matches by prefix, and the route must be covered by it or the session middleware rejects the request before BOT_SECRET is ever checked. /api/ingest/retry-stuck is already covered by the existing /api/ingest entry and needed none of its own — there is a test asserting exactly that. A route placed elsewhere, for example under /api/email/, is not covered by the more specific /api/email/ingest entry and would need its own.
Follow-on worth considering
Transactional sends from lib/email/send.ts write no row at all, while outbound ticket replies in lib/email/reply.ts do — which is why the existing provider webhook can mark those delivered or bounced and cannot do the same here. Recording the welcome send the same way would close the second gap: sent successfully, bounced afterwards, and nothing reflects it.
Acceptance criteria
- A send failure leaves the org in a state a later run can detect and retry
- A retried send happens at most once per org, under concurrency
- Retries are capped and time-bounded
- A successful send is recorded and a second one never fires
- Migration, sweep, and route are covered by tests that fail if the claim stops being atomic
Start here: new to the project? Read CONTRIBUTING.md first. It covers the ground rules, running answerLoops locally, and how to open a pull request.
- Ngôn ngữ chính
- TypeScript
- Star
- 0
- Fork
- 0
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của DeadantCo/answerLoopsdev
-
Widget: match the chat bubble color to the rest of the widgetCó thể đã có người làm @sethr07 đã nhận hôm nay. Đang mởenhancement frontend help wanted
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 75/100
DeadantCo/answerLoopsdev#68 · 3 bình luận ·
-
Widget: make the chat window fit on small phonesCó thể đã có người làm @sethr07 đã nhận hôm nay. Đang mởenhancement frontend good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
DeadantCo/answerLoopsdev#67 · 9 bình luận ·
-
Add 'select all' option to Slack channel picker in SettingsCó thể đã có người làm @sethr07 đã nhận hôm nay. Đang mởfrontend good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
DeadantCo/answerLoopsdev#22 · 5 bình luận ·
-
enhancement frontend help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
DeadantCo/answerLoopsdev#141 ·
-
backend enhancement frontend help wanted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
DeadantCo/answerLoopsdev#140 ·
Tất cả issue của DeadantCo/answerLoopsdev
Issue tương tự
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
lingdojo/kana-dojo#34545 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Blocklist addition requestĐang mởblocklist addition
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
MetaMask/eth-phishing-detect#315455 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: telegram bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
griffinwork40/agent-afk#5275 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
macOS: the Save Diagnostics panel goes behind the editor after an app switch and can't be reachedĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
getopenscreen/openscreen#1667 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
erkamyaman/rust-anything#371 ·
Maintainer thường phản hồi trong vòng 1 ngày