Repository navigation
Fix Resend requests being blocked by Cloudflare (missing User-Agent) - #19
Merged
Merged
Conversation
_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>
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.
_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.