test(auth): cover HTTP 500 status and RFC 7231 Retry-After seconds headers in _retry_delay
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- authentication, testing
Piste de recherche
The work is in _retry_delay in src/openai/auth/_x509.py, with new cases going in tests/test_x509_workload_identity_hardening.py. Read _retry_delay to see the 500/503 status filter and the retry-after seconds parsing against MAX_RETRY_AFTER_DELAY, then run that test file. Done means the proposed boundary test passes and the 500 and standard retry-after assertions fail under the mutations the issue lists. A fork branch with a test patch already exists, so check with maintainers before starting.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Fork Branch with Verified Test Patch
janmejai2002:test/x509-retry-delay-http500-and-headers
PR Brief: Add Unit Test Coverage for HTTP 500 Status and Standard Retry-After Headers in _retry_delay
Repository: openai/openai-python
Target File: src/openai/auth/_x509.py
Target Function: _retry_delay
Test File: tests/test_x509_workload_identity_hardening.py
Patch File: findings/openai-python_fix.patch
Discovery Engine: Cordis Verification Engine (Gate 2 Coverage-Verified Mutation Analysis)
1. Problem Statement
In src/openai/auth/_x509.py, _retry_delay(response: httpx2.Response, attempt: int) -> float | None computes backoff and parses server retry directives for workload identity authentication requests.
Lines 347–350 handle retryable status code filtering:
if response.status_code == 429:
pass
elif response.status_code < 500 or response.status_code != 503:
return None
And lines 364–377 parse standard RFC 7231 Retry-After header values (in seconds):
if retry_after is not None:
try:
delay = float(retry_after)
...
if math.isfinite(delay) and 0 <= delay <= MAX_RETRY_AFTER_DELAY:
return delay
if delay > MAX_RETRY_AFTER_DELAY:
return None
Upstream test coverage in tests/test_x509_workload_identity_hardening.py only exercised custom millisecond headers (x-ms-retry-after-ms) on status 429, and explicit retry status codes 418 and 425. Crucially:
- HTTP 500 status was never asserted. Consequently, mutating line 349 from
response.status_code < 500to<= 500(which would treat 500 as non-retryable and returnNone) survived upstream test runs. - Standard
retry-afterheader with seconds was never asserted. Consequently, mutating line 375 (return delayperturbed toNone) survived upstream test runs.
2. Invariant Fix
Added explicit unit test test_sync_x509_retry_delay_boundaries_and_retry_after in tests/test_x509_workload_identity_hardening.py:
def test_sync_x509_retry_delay_boundaries_and_retry_after() -> None:
req = httpx2.Request("POST", _TOKEN_URL)
# Status 500 must retry
r500 = httpx2.Response(500, request=req)
assert x509_auth._retry_delay(r500, 0) == 0.5
# Standard retry-after seconds header must return delay
r_std = httpx2.Response(429, request=req, headers={"retry-after": "5"})
assert x509_auth._retry_delay(r_std, 0) == 5.0
# Exact boundary MAX_RETRY_AFTER_DELAY must be accepted
r_max = httpx2.Response(429, request=req, headers={"retry-after": str(x509_auth.MAX_RETRY_AFTER_DELAY)})
assert x509_auth._retry_delay(r_max, 0) == x509_auth.MAX_RETRY_AFTER_DELAY
# Exceeding MAX_RETRY_AFTER_DELAY must return None
r_over = httpx2.Response(429, request=req, headers={"retry-after": str(x509_auth.MAX_RETRY_AFTER_DELAY + 1)})
assert x509_auth._retry_delay(r_over, 0) is None
3. Verification & Mutation Kill Rate
- Probe Verification:
report.target_executed == True(probe executed and killed under test suite). - Upstream Mutation Score: 7/10 killed (3 mutants survived).
- Post-Patch Mutation Score: 9/10 killed (1 surviving mutant is mathematically equivalent):
- Line 349 (
<to<= 500): KILLED - Line 375 (
return delaytoNone): KILLED - Line 376 (
>to<= MAX_RETRY_AFTER_DELAY): KILLED - Line 376 (
>to>= MAX_RETRY_AFTER_DELAY): Equivalent mutant (unreachable because line 374 already matches and returns whendelay == MAX_RETRY_AFTER_DELAY).
- Line 349 (
- Pytest Output: Clean pass (
1 passed, 154 deselected in 0.22s).
- Langage dominant
- Python
- Étoiles
- 32.2k
- Forks
- 5.8k
- Merge moyen
- 12 h 29 min
- PR mergées (30 j)
- 112
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de openai/openai-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
openai/openai-python#4338 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
openai/openai-python#4337 ·
Les mainteneurs répondent en général sous 1 jour
-
`BaseClient._prepare_url()` corrupts relative endpoint URLs when `base_url` contains query parametersPeut-être pris @Rewaskc02-lang l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
openai/openai-python#4311 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
openai/openai-python#4310 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
openai/openai-python#4309 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de openai/openai-python
Issues similaires
-
triage
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
kornia/kornia-rs#1416 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
ui
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
PolicyEngine/ai-inequality#64 ·
Les mainteneurs répondent en général sous 1 jour
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timePeut-être pris @PabloRoque l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
pymc-devs/pymc-extras#839 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour