Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto Apto para principiantes
#1,232 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@auraseb ya está trabajando en esto.

Desde el 18/10/2026.

  • #1233 de @auraseb — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api, backend

Línea de trabajo

Lee el bucle de sondeo en planet/clients/data.py y compáralo con OrdersClient.wait, que, según indica el issue, cuenta los intentos correctamente. Reproduce el caso con max_attempts=2, en el que la segunda respuesta tiene el estado active, e inspecciona si se comprueba el último estado obtenido antes de generar el error del límite. El trabajo estará listo cuando se devuelva la última respuesta activa y el callback reciba active, mientras que un asset que siga inactivo al alcanzar el límite genere el error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
300
Forks
100
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de planetlabs/planet-client-python

Todos los issues de planetlabs/planet-client-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.