Async fetch_related_object_async / fetch_event_async send "usage" as an API parameter
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 90/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
Empieza por raw_request y raw_request_async en stripe/_stripe_client.py y luego rastrea los helpers de eventos asíncronos que pasan usage. Ejecuta la reproducción proporcionada contra stripe-mock y confirma que las solicitudes GET y POST asíncronas omiten el parámetro interno usage y conservan los datos de telemetría proporcionados por el llamante; agrega o actualiza pruebas enfocadas del cliente para ambas rutas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
StripeClient.raw_request_async does not remove the internal usage keyword from params the way raw_request does. The SDK's own event notification helpers pass usage=[...] to it, so every async fetch adds usage[0]=... to the request.
For a related object with a v1 URL the API rejects the request as an unknown parameter. Against stripe-mock:
sync: Meter
async error: InvalidRequestError Request req_123: Request validation error: ... additional properties are not allowed
Request URLs observed with a stub HTTP client for the same notification:
sync get https://api.stripe.com/v1/accounts/acct_123
async get https://api.stripe.com/v1/accounts/acct_123?usage[0]=fetch_related_object
fetch_event_async() has the same problem (/v2/core/events/evt_...?usage[0]=pushed_event_pull&usage[1]=pushed_event_pull_async). The request telemetry also reports ["raw_request", "async"] instead of the usage the caller passed.
What should happen
The async path should behave like the sync path: usage is consumed as telemetry and never sent to the API.
Minimal repro
import asyncio, json, stripe
client = stripe.StripeClient("sk_test_123", base_addresses={"api": "http://localhost:12111"}) # stripe-mock
payload = json.dumps({
"id": "evt_1", "object": "v2.core.event",
"type": "v1.billing.meter.error_report_triggered",
"created": "2024-01-01T00:00:00Z", "livemode": False,
"related_object": {"id": "mtr_123", "type": "billing.meter", "url": "/v1/billing/meters/mtr_123"},
})
notif = client.parse_event_notification_without_verification(payload)
notif.fetch_related_object() # works
asyncio.run(notif.fetch_related_object_async()) # InvalidRequestError
Root cause
In stripe/_stripe_client.py, raw_request does usage = params.pop("usage", ["raw_request"]), but raw_request_async hardcodes usage=["raw_request"] and leaves usage inside params, which are then encoded into the query string (GET) or body (POST).
Tested on master at aff846c (16.0.0).
- Lenguaje dominante
- Python
- Estrellas
- 2.1k
- Forks
- 539
- Merge medio
- 3 d 5 h
- PR fusionados (30 d)
- 17
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stripe/stripe-python
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
stripe/stripe-python#1947 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
stripe/stripe-python#1936 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
feature-request future
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
stripe/stripe-python#1941 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Add support for HTTPX2Abiertofeature-request future
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
stripe/stripe-python#1886 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
feature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 54/100
stripe/stripe-python#1841 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de stripe/stripe-python
Issues similares
-
idxmax/idxmin raise ValueError when a single partition is all-NAPosiblemente ocupada @Jason10191019999 la tomó hoy. Abiertoneeds triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 3 días
-
Old versions of datamodelsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
[BUG]: Windows GUI package of v1.17.0-rc3 has no GTK DLLsPosiblemente ocupada @andrut-ds la tomó hoy. Abiertobug CI/CD Pactus-GUI Windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
pactus-project/pactus#2428 ·
Los mantenedores suelen responder en 1 día
-
DiskDataset.reshard() can hang with a zero or negative shard sizePosiblemente ocupada @Programmer-Develops la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 19 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
GNS3/gns3-server#3017 · 1 comentario ·
Los mantenedores suelen responder en 1 día