Container credentials client sleeps after the final failed attempt
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- authentication
Línea de trabajo
Comienza en HttpCredentialsClient.get_credentials() e inspecciona el bucle de reintento para el manejo de excepciones descrito en el issue. Añade o actualiza una prueba de regresión que haga mock de asyncio.sleep y verifique que dos intentos producen un sleep, mientras que un fallo final se produce inmediatamente; el SmithyIdentityError terminal debe permanecer sin cambios.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
HttpCredentialsClient.get_credentials() waits for the retry delay after every failed attempt, including the final attempt when no retry remains. This adds one second of unnecessary latency before the client raises its terminal SmithyIdentityError.
With the default three attempts, a terminal failure incurs three one-second sleeps even though only two delays are needed between attempts. With retries=1, the single request still takes about one extra second to fail.
Regression Issue
This does not appear to be a regression.
Expected Behavior
The client should sleep only between attempts. After the final attempt fails, it should raise immediately.
Current Behavior
The except block awaits asyncio.sleep(_SLEEP_SECONDS) before incrementing/checking the attempt count, so the final failure always sleeps before leaving the loop.
Reproduction Steps
import asyncio
from time import monotonic
from aws_credentials_http.client import HttpCredentialsClient
from smithy_core import URI
from smithy_core.exceptions import SmithyIdentityError
from smithy_http import Fields
class FailingClient:
async def send(self, *args, **kwargs):
raise OSError("endpoint unavailable")
async def main():
client = HttpCredentialsClient(FailingClient(), retries=1) # type: ignore[arg-type]
started = monotonic()
try:
await client.get_credentials(
URI(scheme="http", host="169.254.170.2", path="/credentials"),
Fields(),
)
except SmithyIdentityError:
print(f"elapsed: {monotonic() - started:.1f}s")
asyncio.run(main())
On aws-credentials-http==0.3.0, this prints approximately elapsed: 1.0s even though only one request is configured and there is no subsequent retry to wait for.
Possible Solution
Increment the attempt count first, then await the retry delay only when attempts < self._retries. A regression test can mock asyncio.sleep and assert that two attempts produce one sleep.
Additional Information/Context
Confirmed against the current develop branch (5fed4da) and the latest published aws-credentials-http release, 0.3.0.
Affected area
credentials / authentication
Affected package(s)
aws-credentials-http 0.3.0
Python version used
Python 3.14.0
Operating System and version
macOS 27.0.1
- Lenguaje dominante
- Python
- Estrellas
- 175
- Forks
- 24
- Merge medio
- 2 d 7 h
- PR fusionados (30 d)
- 9
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aws/aws-sdk-python
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
aws/aws-sdk-python#13 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
aws/aws-sdk-python#99 ·
Los mantenedores suelen responder en 1 día
-
Support Python 3.11Abiertofeature-request p3 queued
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
aws/aws-sdk-python#92 ·
Los mantenedores suelen responder en 1 día
-
announcement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
aws/aws-sdk-python#90 ·
Los mantenedores suelen responder en 1 día
-
announcement
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
aws/aws-sdk-python#84 ·
Los mantenedores suelen responder en 1 día
Todos los issues de aws/aws-sdk-python
Issues similares
-
Link Checker ReportAbiertoautomated issue report
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
RapidAI/RapidOCRDocs#119 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
btclib-org/btclib-node#1833 ·
Los mantenedores suelen responder en 1 día
-
IRIS reader: no-data velocity bins (DB_VEL, DB_VELC) returned as 0.0 m/s instead of NaNPosiblemente ocupada @syedhamidali la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
elodin-sys/elodin#890 ·
Los mantenedores suelen responder en 1 día