Skip to content

WIP: fix HTTP-date Retry-After handling - #135

Closed
Kayvan-Zahiri wants to merge 1 commit into
OneSignal:mainfrom
Kayvan-Zahiri:codex/honor-http-date-retry-after
Closed

Kayvan-Zahiri wants to merge 1 commit into
OneSignal:mainfrom
Kayvan-Zahiri:codex/honor-http-date-retry-after

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Description

One Line Summary

Honor HTTP-date Retry-After headers when retrying notifications, including past dates and obsolete HTTP-date formats.

Details

Motivation

Fixes #134. The retry helper currently parses only numeric delays. A valid 503/429 response asking the client to wait until a future HTTP date instead falls back to a one-second delay, retrying too early.

Keep existing numeric parsing and parse HTTP dates using email.utils.parsedate_to_datetime. Treat timezone-free obsolete HTTP dates as UTC, calculate the remaining wall-clock delay, clamp past dates to zero, and retain exponential fallback for malformed headers.

The standard-library parser avoids a local-time calculation bug observed in urllib3 1.25.3, the SDK's minimum declared version. No new dependency, public API, retryable status, or idempotency behavior is introduced.

Protocol reference: RFC 9110 section 10.2.3.

Testing

Manual testing

Automated local SDK execution with mocked API responses, clock, and sleep; human device testing is not claimed.

  • Before: 8 failed, 8 passed new public DefaultApi.create_notification_with_retry cases.
  • After: full pytest --cov=onesignal — 195 passed on Python 3.12 / urllib3 2.8.0.
  • Compatibility: all 16 new cases pass on Python 3.9 / urllib3 1.25.3. That old dependency cannot import on Python 3.12, so the compatible older runtime was used; no dependency change is included.
  • Tests cover 429/503, modern/RFC850/asctime dates, past dates, numeric/zero, malformed and absent headers, same-key retry preservation, and replay reporting.
  • Changed-file Ruff F/E9 checks, compilation, and git diff --check pass. Full supported Python/dependency matrix and hosted delivery were not run.
  • No notifications, hosted accounts, real credentials, paid resources, or UI automation.

Checklist

  • Required sections completed.
  • PR does one thing.
  • No public API shape change.
  • Relevant automated tests executed locally.
  • Human device testing and self-review pending; this is a draft.

AI assistance: OpenAI Codex investigated, implemented, tested, and prepared this draft. Human verification is not claimed.

@sherwinski

Copy link
Copy Markdown
Contributor

Closing with #134, see the comment there for more details.

@sherwinski sherwinski closed this Oct 28, 2026
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.

Idempotent retry helper ignores HTTP-date Retry-After values

2 participants