Skip to content

Fix Resend requests being blocked by Cloudflare (missing User-Agent) - #19

Merged
Yajat-Sharma merged 1 commit into
mainfrom
feature/monthly-summary-service
Sep 28, 2026
Merged

Yajat-Sharma merged 1 commit into
mainfrom
feature/monthly-summary-service

Conversation

@Yajat-Sharma

Copy link
Copy Markdown
Owner

_post_to_resend() sent no User-Agent header, so it fell through to Python's default "Python-urllib/x.y" signature -- Resend's Cloudflare WAF blocks that outright (HTTP 403, Cloudflare error 1010) before the request ever reaches Resend's own API. Found during a controlled real -send verification against Resend's sandbox sender (onboarding@resend.dev -> yajats@gmail.com, using a disposable local SQLite database, never production Neon): the request was rejected by Cloudflare, not Resend, until a normal User-Agent was added, after which Resend accepted it (200) and the local delivery row correctly recorded SENT.

Also captures the HTTPError response body (previously only status/reason) so a future failure like the "domain not verified" 403 encountered during this same verification is diagnosable from the stored error message alone, without needing to reproduce it manually.

send_weekly_summary() in app.py and _send_via_resend() in services/pin_recovery_service.py have the same missing-User-Agent gap and are very likely affected the same way in production -- deliberately left untouched here, out of scope for this fix.

_post_to_resend() sent no User-Agent header, so it fell through to
Python's default "Python-urllib/x.y" signature -- Resend's Cloudflare
WAF blocks that outright (HTTP 403, Cloudflare error 1010) before the
request ever reaches Resend's own API. Found during a controlled real
-send verification against Resend's sandbox sender (onboarding@resend.dev
-> yajats@gmail.com, using a disposable local SQLite database, never
production Neon): the request was rejected by Cloudflare, not Resend,
until a normal User-Agent was added, after which Resend accepted it
(200) and the local delivery row correctly recorded SENT.

Also captures the HTTPError response body (previously only status/reason)
so a future failure like the "domain not verified" 403 encountered
during this same verification is diagnosable from the stored error
message alone, without needing to reproduce it manually.

send_weekly_summary() in app.py and _send_via_resend() in
services/pin_recovery_service.py have the same missing-User-Agent gap
and are very likely affected the same way in production -- deliberately
left untouched here, out of scope for this fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Yajat-Sharma
Yajat-Sharma merged commit 6733921 into main Sep 28, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant