Skip to content

Make retries duplicate-safe and refuse cross-host redirects - #41

Merged
archlemon merged 1 commit into
mainfrom
fix/retry-safety
Nov 14, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/retry-safety

Conversation

@archlemon

Copy link
Copy Markdown
Member

Fixes #32, fixes #34 (both from the fresh review, reproduced there).

Retries no longer duplicate (Temporary = nothing was delivered or server explicitly said retry):

before now
SMTP QUIT fails after DATA accepted error, retried → 2 mails ignored, success
SMTP net error during end-of-DATA ack retried permanent (server may have accepted)
SMTP 4xx reply retried retried
HTTP dial/DNS failure retried retried
HTTP timeout after request sent retried permanent
HTTP 500 retried permanent
HTTP 429/502/503/504 retried retried

Redirects: CheckRedirect follows only same-host hops (max 10); cross-host → refusing redirect to another host (...). Go otherwise re-sends the body and non-Authorization headers on 307/308. The client is now always a dedicated http.Client (insecure mode still clones DefaultTransport).

README, flag help, and example comment describe what is retried.

Tests: status classification table, timeout-after-send not temporary, cross-host redirect refused and target never hit, same-host redirect followed, ambiguous SMTP net error permanent, fake SMTP server dropping the connection after 250 → Send succeeds.

Retries could deliver a notification twice:
- SMTP: a failed QUIT after the server accepted DATA was a net.Error,
  hence retried. Ignore QUIT errors once DATA is accepted, and treat
  network errors while the end of DATA is acknowledged as permanent.
  4xx replies stay retryable since they mean the message was refused.
- HTTP: timeouts after the request was written and 500s were retried.
  Only dial/DNS failures and 429/502/503/504 are temporary now.

Go's client follows 307/308 to any host and re-sends the body and
custom headers (X-Api-Key, form tokens). Follow redirects only within
the original host.

Fixes #32
Fixes #34
@archlemon archlemon added bug Something isn't working security Security-relevant fix or hardening labels Nov 14, 2026
@archlemon
archlemon merged commit f69faf6 into main Nov 14, 2026
2 checks passed
@archlemon
archlemon deleted the fix/retry-safety branch November 14, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working security Security-relevant fix or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP redirects forward custom headers and form secrets to other hosts Retries can deliver a notification twice

1 participant