Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Container credentials client sleeps after the final failed attempt

Đang mở Phù hợp với người mới
#106 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@gauravkriplani đang làm issue này rồi.

Từ ngày 3/10/2026.

  • #107 của @gauravkriplani — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
authentication

Hướng nghiên cứu

Bắt đầu từ HttpCredentialsClient.get_credentials() và kiểm tra vòng lặp retry xử lý ngoại lệ được mô tả trong issue. Thêm hoặc cập nhật một bài kiểm thử hồi quy mock asyncio.sleep và xác minh rằng hai lần thử tạo ra một sleep, trong khi một lỗi cuối cùng được raise ngay lập tức; SmithyIdentityError terminal vẫn phải được giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
173
Fork
23
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
9

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws/aws-sdk-python

Tất cả issue của aws/aws-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.