Async fetch_related_object_async / fetch_event_async send "usage" as an API parameter
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 90/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
- backend-api-design
Hướng nghiên cứu
Bắt đầu với raw_request và raw_request_async trong stripe/_stripe_client.py, sau đó lần theo các helper sự kiện bất đồng bộ truyền usage. Chạy quy trình tái hiện được cung cấp với stripe-mock và xác nhận rằng các yêu cầu GET và POST bất đồng bộ bỏ qua tham số nội bộ usage nhưng vẫn giữ nguyên dữ liệu telemetry do bên gọi cung cấp; thêm hoặc cập nhật các test client tập trung cho cả hai luồng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Python
- Star
- 2.1k
- Fork
- 539
- Merge trung bình
- 3 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 stripe/stripe-python
-
Boolean list elements are encoded as True/False instead of true/falseCó thể đã có người làm @inchang-ing đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
stripe/stripe-python#1947 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
stripe/stripe-python#1936 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature-request future
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
stripe/stripe-python#1941 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add support for HTTPX2Đang mởfeature-request future
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
stripe/stripe-python#1886 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature-request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 54/100
stripe/stripe-python#1841 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stripe/stripe-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to itCó thể đã có người làm @anasamin26 đã nhận hôm nay. Đang mởbug enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aden-hive/hive#7508 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
llm translation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BerriAI/litellm#47884 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/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
netalertx/NetAlertX#1856 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày