Async fetch_related_object_async / fetch_event_async send "usage" as an API parameter
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 90/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 stripe/_stripe_client.py 中的 raw_request 和 raw_request_async 开始,然后跟踪传递 usage 的异步事件辅助函数。针对 stripe-mock 运行提供的复现步骤,并确认异步 GET 和 POST 请求会省略内部参数 usage,同时保留调用方提供的遥测数据;为这两条路径添加或更新有针对性的客户端测试。
由索引模型根据 Issue 内容生成。
描述
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).
- 主要语言
- Python
- 星标
- 2.1k
- 派生
- 539
- 平均合并
- 3 天 5 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
stripe/stripe-python 的其他 Issue
-
Boolean list elements are encoded as True/False instead of true/false可能已有人在做 @inchang-ing 于 1 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
stripe/stripe-python#1947 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
stripe/stripe-python#1936 · 2 条评论 ·
维护者通常 1 天内回复
-
feature-request future
难度 4/5 3-5 天 新手友好度 55/100
stripe/stripe-python#1941 · 6 条评论 ·
维护者通常 1 天内回复
-
feature-request future
难度 4/5 3-5 天 新手友好度 35/100
stripe/stripe-python#1886 · 2 条评论 ·
维护者通常 1 天内回复
-
feature-request
难度 2/5 1-3 小时 新手友好度 54/100
stripe/stripe-python#1841 · 1 条评论 ·
维护者通常 1 天内回复
查看 stripe/stripe-python 的全部 Issue
相似的 Issue
-
infrastructure
难度 2/5 1-3 小时 新手友好度 74/100
khuisman/mcp-gee-sweet#1152 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
backroom bug
难度 2/5 1-3 小时 新手友好度 68/100
ditto-assistant/ditto-subnet#3069 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 67/100
open-webui/open-webui#32901 · 1 条评论 ·
维护者通常 1 天内回复
-
0.3.3 bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复