Skip to content

Bug: Binance Python SPOT SDK Websocket API user_data_stream_subscribe() method is failing #520

@nikita-doronin

Description

@nikita-doronin

Websocket API user_data_stream_subscribe() method for Python SPOT SDK is failing with the error: 'dict' object has no attribute 'result'.

response.data() is returning a raw dict instead of a UserDataStreamSubscribeResponse model object. When the SDK then tries to access data.result, it fails because dicts use data['result'], not attribute access.

This is a deserialisation bug in the Binance Spot SDK:

  1. Internally, the SDK sends the WS message and calls response.data() to parse the reply
  2. If the WS request times out or encounters an error, the SDK silently returns {"error": "timeout"} (a raw dict) instead of a UserDataStreamSubscribeResponse model.
  3. The SDK then tries data.result.subscription_id on that dict, which crashes with 'dict' object has no attribute 'result'
# Inside binance_sdk_spot/websocket_api/websocket_api.py:
response = await self._userDataStreamApi.user_data_stream_subscribe(id)
data = response.data()
stream = await RequestStream(
    self,
    data.result.subscription_id,  # ERROR IS HERE
    ...
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions