SPOT : UserDataStreamEventsResponse does not deserialize correctly, instance is always None
还没有人认领这个 Issue。
评估
调研方向
从 UserDataStreamEventsResponse.model_validate 和相关的具体事件模型开始,然后将判别联合的行为与 #476 中的 SymbolFilters 问题以及相关问题 #405 进行比较。当诸如 balanceUpdate 这样的事件生成一个类型化的事件实例并保留其字段,而不是让 actual_instance 保持为 None 时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Description
The UserDataStreamEventsResponse model fails to parse user data stream events into their concrete event types (BalanceUpdate, ExecutionReport, OutboundAccountPosition, EventStreamTerminated, etc.). All input results in None and the event data is completely lost.
Expected Behavior
When validating a user data stream event, the model should:
- Parse the event dictionary into the appropriate concrete event type based on the
"e"field - Return a strongly-typed instance (e.g.,
BalanceUpdate,ExecutionReport) - Preserve all event data fields
Example:
from binance_sdk_spot.websocket_api.models import UserDataStreamEventsResponse
event = {
"e": "balanceUpdate",
"E": 1573200697110,
"a": "BTC",
"d": "100.00000000",
"T": 1573200697068
}
result = UserDataStreamEventsResponse.model_validate(event)
# Expected: result is a BalanceUpdate instance with all fields accessible
# Expected: result.a == "BTC"
# Expected: result.d == "100.00000000"
# Expected: result.E == 1573200697110
# Expected: result.e == "balanceUpdate"
# Expected: result.T == 1573200697068
Actual Behavior
The parsing always fails and returns None, losing all event data:
result = UserDataStreamEventsResponse.model_validate(event)
# Actual: result.actual_instance is None
# Actual: All event data is lost
# Actual: Cannot access event fields
Possible Root Cause
The model uses Pydantic's discriminated union pattern but fails to properly discriminate between event types. Issues include:
- Schema Validation Failure: The discriminator field or schema mapping is not correctly configured
- Type Resolution Failure: The model cannot resolve which concrete event type to instantiate
- Silent Failure: Instead of raising validation errors, it silently returns
None
This is similar to the SymbolFilters discriminated union issue that was previously identified, where filter type discrimination failed.
Impact
- Complete Data Loss: All user data stream events are lost when using this model
- No Balance Updates: Balance changes from
outboundAccountPositionevents cannot be processed - No Order Updates: Order status changes from
executionReportevents cannot be tracked - No Stream Monitoring: Stream termination events cannot be detected
Related Issues
- Similar to #476 discriminated union parsing issue
References
Affected Version: >=2.1.0
Related or same as #405
- 主要语言
- Python
- 星标
- 3k
- 派生
- 712
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 4
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
binance/binance-connector-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 88/100
binance/binance-connector-python#570 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
binance/binance-connector-python#514 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 4/5 3-5 天 新手友好度 15/100
binance/binance-connector-python#575 · 1 条评论 ·
查看 binance/binance-connector-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
anchore/grype-db#1149 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sites可能已有人在做 @HootRock 今天认领。 未关闭comp/cli P2 type/perf
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#142417 · 2 条评论 ·
维护者通常 1 天内回复
-
SMC SPEC
难度 2/5 1-3 小时 新手友好度 70/100
tenstorrent/tt-oca-harness#3287 ·
维护者通常 1 天内回复
-
bug enhancement python
难度 2/5 1-3 小时 新手友好度 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 72/100
fabriziosalmi/wildbox#801 ·
维护者通常 1 天内回复