Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#1,232 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@auraseb がすでに取り組んでいます。

2026年10月18日 から。

  • #1233 @auraseb による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

planet/clients/data.py のポーリングループを読み、issue によると試行回数を正しく数える OrdersClient.wait と比較してください。2 回目の応答のステータスが active となる max_attempts=2 のケースを再現し、上限エラーを発生させる前に最後に取得したステータスが確認されているか調べてください。最後の応答が active の場合はそれが返され、コールバックが active を受け取る一方、上限に達してもアセットが inactive のままならエラーが発生すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
300
フォーク
100
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

planetlabs/planet-client-python のほかの issue

planetlabs/planet-client-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。