Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Container credentials client sleeps after the final failed attempt

Offen Anfängerfreundlich
#106 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@gauravkriplani arbeitet bereits daran.

Seit 03.10.2026.

  • #107 von @gauravkriplani — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
authentication

Rechercherichtung

Beginne bei HttpCredentialsClient.get_credentials() und untersuche die im Issue beschriebene Retry-Schleife zur Ausnahmebehandlung. Füge einen Regressionstest hinzu oder aktualisiere ihn, der asyncio.sleep mockt und verifiziert, dass zwei Versuche zu einem sleep führen, während ein endgültiger Fehler sofort ausgelöst wird; der abschließende SmithyIdentityError soll unverändert bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Python
Sterne
173
Forks
23
Ø Merge
2 T. 7 Std.
Gemergte PRs (30 T.)
9

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus aws/aws-sdk-python

Alle Issues in aws/aws-sdk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.