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

DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset

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

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

Từ ngày 18/10/2026.

  • #1233 của @auraseb — đ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
82/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
api, backend

Hướng nghiên cứu

Đọc vòng lặp polling trong planet/clients/data.py và so sánh với OrdersClient.wait, nơi issue cho biết xử lý đúng việc đếm số lần thử. Tái hiện trường hợp với max_attempts=2, trong đó phản hồi thứ hai có trạng thái active, và kiểm tra xem trạng thái được lấy cuối cùng có được kiểm tra trước khi phát sinh lỗi giới hạn hay không. Hoàn tất khi phản hồi active cuối cùng được trả về và callback nhận active, còn một asset vẫn inactive khi chạm giới hạn thì phát sinh lỗi.

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

Mô tả

What happens

DataClient.wait_asset (and Planet().data.wait_asset and planet data asset-wait, which call it) fetches the asset on each attempt but only checks the status at the top of the next loop iteration. When the asset becomes active on the final allowed poll, the loop ends on the attempt count, the fresh status is never looked at, and a ClientError("Maximum number of attempts (N) reached.") is raised. The callback is also never called with active.

What should happen

If the last poll returns active, wait_asset should return that asset, the same as it does when activation finishes on any earlier poll. The error should only be raised when the asset is still not active after max_attempts polls.

Minimal repro

import asyncio, copy, httpx, respx
from planet import DataClient, Session, Auth

URL = "https://example.test/asset"
asset = {"_links": {"_self": URL}, "status": "activating"}
active = copy.deepcopy(asset)
active["status"] = "active"

@respx.mock
async def main():
    respx.get(URL).side_effect = [
        httpx.Response(200, json=asset),
        httpx.Response(200, json=active),
    ]
    async with Session(auth=Auth.from_key("x")) as sess:
        cl = DataClient(sess)
        print(await cl.wait_asset(asset, delay=0, max_attempts=2))

asyncio.run(main())

Output:

planet.exceptions.ClientError: Maximum number of attempts (2) reached.

The second and last poll returned "status": "active".

Root cause

In planet/clients/data.py, the loop condition is while not max_attempts or num_attempts < max_attempts, and the new asset is fetched at the bottom of the loop body after num_attempts += 1. When num_attempts reaches max_attempts the loop exits before the status check at the top runs, and the check after the loop only looks at num_attempts. OrdersClient.wait does not have this problem because it polls at the top of the loop and checks the state before counting the attempt.

Ngôn ngữ chính
Python
Star
300
Fork
100
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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 planetlabs/planet-client-python

Tất cả issue của planetlabs/planet-client-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.