Container credentials client sleeps after the final failed attempt
Maintainer antworten meist innerhalb von 1 Tag
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
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
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus aws/aws-sdk-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
aws/aws-sdk-python#13 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
aws/aws-sdk-python#99 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Support Python 3.11Offenfeature-request p3 queued
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
aws/aws-sdk-python#92 ·
Maintainer antworten meist innerhalb von 1 Tag
-
announcement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
aws/aws-sdk-python#90 ·
Maintainer antworten meist innerhalb von 1 Tag
-
announcement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
aws/aws-sdk-python#84 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in aws/aws-sdk-python
Ähnliche Issues
-
needs-human needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
gke-labs/kube-agents#2400 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Device Details tables: FS/SF columns contradict each other (nfet_01v8 Vt row, pfet_01v8 Idsat row)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
google/skywater-pdk#450 ·
-
Drained trajectory arrays are overwritten when the sequence buffer is reusedEvtl. vergeben @sylvesterkaczmarek hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
google-deepmind/bsuite#56 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
LearningCircuit/local-deep-research#7206 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
chingu-voyages/V62-tier3-team-33#285 ·
Maintainer antworten meist innerhalb von 1 Tag