Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Container credentials client sleeps after the final failed attempt

Abierto Apto para principiantes
#106 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@jonathan343 ya está trabajando en esto.

Desde el 5/10/2026.

  • #107 de @gauravkriplani — abierto

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

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

bug p2
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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws/aws-sdk-python

Todos los issues de aws/aws-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.