SPOT : UserDataStreamEventsResponse does not deserialize correctly, instance is always None
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with UserDataStreamEventsResponse.model_validate and the related concrete event models, then compare the discriminated-union behavior with the SymbolFilters issue in #476 and the related issue #405. Done means an event such as balanceUpdate produces a typed event instance and preserves its fields instead of leaving actual_instance as None.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 699
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from binance/binance-connector-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
binance/binance-connector-python#514 · 1 comment ·
-
Answered
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
binance/binance-connector-python#502 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
binance/binance-connector-python#553 · 2 comments ·
-
Answered
Difficulty 3/5 1-2 days Newbie friendliness 68/100
binance/binance-connector-python#513 · 2 comments ·
-
Answered
Difficulty 2/5 1-3 hours Newbie friendliness 56/100
binance/binance-connector-python#512 · 1 comment ·
All issues in binance/binance-connector-python
Similar issues
-
area: harness bug status: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Human-Agent-Society/reef#625 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
learningequality/kolibri#15351 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Name consistency Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
eellak/triplestore#65 · 1 comment ·