Skip to content

Make retries and failover safe for requests that change state - #4

Merged
secretpray merged 2 commits into
nextfrom
fix/reliability
Nov 9, 2026
Merged

secretpray merged 2 commits into
nextfrom
fix/reliability

Conversation

@secretpray

Copy link
Copy Markdown
Collaborator

Summary

  • Safe failover and retries. A request that changes something (starting or stopping a session, setting prices) is resent, to the same or another API host, only when the connection could not be established. Before, a timeout sent it to the next host, which could start a session twice.
  • Retries after network errors. GET, PUT and DELETE requests are retried after connection errors and timeouts, not only after error responses.
  • Retry-After. The wait is capped by the new max_retry_after option (OCTA_MAX_RETRY_AFTER, 60 seconds by default); a longer wait raises RateLimitError at once. The header is also accepted as an HTTP date.
  • Errors. HTTP 400 raises ValidationError (a subclass of APIError, so existing except APIError keeps working); HTTP 409 raises the new ConflictError. Every transport failure raises APIConnectionError or APITimeoutError instead of an httpx exception.
  • Configuration. ConfigurationError is also a ValueError; invalid OCTA_* numbers raise it with the variable name. The API token no longer appears in repr(ClientConfig).
  • Guides, docstrings and the changelog describe the new behaviour.

Verification

  • ruff check, ruff format --check, mypy (strict), pytest: 78 passed, 100% coverage
  • new tests for each case: POST after a timeout and after a connection failure, GET retry after a connection error, Retry-After cap and HTTP date, 400/409 mapping, token not in repr, invalid environment numbers
  • every code example in the README and the guides runs against the package with mocked HTTP

A request that starts or stops a session or sets prices is now resent,
to the same or another API host, only when the connection could not be
established; a timeout no longer sends it a second time. GET, PUT and
DELETE requests are also retried after connection errors and timeouts.

Retry-After is capped by the new max_retry_after option (60 seconds) and
accepts an HTTP date. HTTP 400 raises ValidationError and HTTP 409 the
new ConflictError. ConfigurationError is also a ValueError, and invalid
OCTA_* numbers raise it. The API token is left out of repr(ClientConfig).
@secretpray
secretpray merged commit d5e5716 into next Nov 9, 2026
5 checks passed
@secretpray
secretpray deleted the fix/reliability branch November 9, 2026 09:41
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