Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Lack of built-in retry mechanism for handling transient network errors and rate limits

オープン
#20 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python

調査の方向性

Read the synchronous and asynchronous client constructors and the HTTP request paths for Client, AsyncClient, OauthClient, and AsyncOauthClient. Check how the SDK handles network errors, response status codes, and Retry-After headers, then identify the tests covering those paths. Done means opt-in retries work across all four clients with backoff, jitter, rate-limit handling, and the stated defaults.

索引モデルが issue の本文から書いたものです。

説明

Currently, the OpenAPI Python SDK is designed with low-level HTTP primitives. If an API request fails due to a transient error, the client raises an error or fails immediately:

  1. Transient Network Errors: Minor network drops, socket timeouts, or DNS hiccups fail immediately.
  2. Temporary Server Overloads: Gateway errors (HTTP 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout) trigger immediate crashes.
  3. Rate Limits (HTTP 429): If the client hits API rate limits, it fails instantly rather than waiting for the reset window.

To handle these scenarios, developers using the SDK must write custom retry loops and catch blocks in their application code, leading to unnecessary boilerplate.


Proposed Feature

Implement an optional, built-in retry mechanism for both synchronous and asynchronous clients (Client, AsyncClient, OauthClient, and AsyncOauthClient).

This retry mechanism should feature:

  1. Exponential Backoff: Gradually increase wait times between retries (e.g. wait 1s, then 2s, then 4s) to give the server time to recover.
  2. Jitter (Randomized Noise): Add random variation to the sleep durations to prevent multiple clients from hitting the server at the exact same millisecond.
  3. Smart Rate-Limit Handling: Automatically detect HTTP 429 status codes, parse the Retry-After header if available, and sleep for the requested duration before retrying.
  4. Customizable Configuration: Allow developers to configure the retries during client initialization, with safe defaults.

Proposed API Design

Add optional retry parameters to the client constructors:

client = Client(
    token="your_token",
    max_retries=3,          # Number of retry attempts (0 to disable)
    backoff_factor=1.0,     # Multiplier for exponential sleep delay
    retry_on_status=[429, 502, 503, 504]  # Status codes that trigger a retry
)

To ensure 100% backward compatibility, max_retries should default to 0 (disabled), ensuring no existing production code or tests are affected unless the developer explicitly opts in.


Benefits
  • Resilience: SDK handles transient internet drops and brief server downtime gracefully.
  • Ease of Use: Reduces boilerplate code in the consumer's application.
  • Backward-Compatible: Defaulting max_retries to 0 guarantees existing behavior is preserved.
主要言語
Python
スター
18
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openapi/openapi-python-sdk のほかの issue

openapi/openapi-python-sdk の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。