Container credentials client sleeps after the final failed attempt
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-sdk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/aws-sdk-python#13 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
aws/aws-sdk-python#99 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support Python 3.11Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
aws/aws-sdk-python#92 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
announcement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
aws/aws-sdk-python#90 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
announcement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws/aws-sdk-python#84 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/aws-sdk-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Qiskit/qiskit-ibm-runtime#3431 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Lesson] A compatibility-gate rejection is a verdict, not something to overwrite with --accept-riskĐang mởlesson-submission needs-ac pending-review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Ikalus1988/MisakaNet#2870 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature:LinkChecker
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
digitalfabrik/integreat-cms#4594 ·
Maintainer thường phản hồi trong vòng 5 ngày