Skip to content

fix(common): use enum values in WebSocket stream names - #577

Open
Amadeus-22 wants to merge 1 commit into
binance:masterfrom
Amadeus-22:fix/ws-stream-enum-params
Open

Amadeus-22 wants to merge 1 commit into
binance:masterfrom
Amadeus-22:fix/ws-stream-enum-params

Conversation

@Amadeus-22

Copy link
Copy Markdown
Contributor

The generated stream methods are typed to take enums (spot kline(interval: KlineIntervalEnum), ticker_rolling_window(window_size: ...), futures continuous_contract_kline_candlestick_streams(contract_type: ..., interval: ...) and others), but ws_streams_placeholder fills placeholders with str(value), so passing the enum builds a stream name that doesn't exist:

ws_streams_placeholder("<symbol>@kline_<interval>", {"symbol": "BTCUSDT", "interval": KlineIntervalEnum.INTERVAL_1m})
# 'btcusdt@kline_KlineIntervalEnum.INTERVAL_1m'   expected 'btcusdt@kline_1m'

ws_streams_placeholder("<symbol>@ticker_<windowSize>", {"symbol": "BTCUSDT", "window_size": WindowSizeEnum.WINDOW_SIZE_1h})
# 'btcusdt@ticker_windowsizeenum.window_size_1h'

The subscription is accepted but never receives data; the examples only work because they pass .value. The REST (make_serializable) and WebSocket API paths already unwrap enums; this does the same for stream names.

Added TestWsStreamsPlaceholder.test_enum_values_are_unwrapped (kline, continuousKline, ticker window size). It fails on master and passes with the fix; pytest tests/unit in common/ passes (404). flake8 is clean; black --check flags only a pre-existing docstring in RedactedRepr, untouched here.

🤖 Generated with Claude Code

ws_streams_placeholder filled placeholders with str(value), so an enum
passed to a generated stream method (e.g. spot kline(interval=
KlineIntervalEnum.INTERVAL_1m)) produced btcusdt@kline_KlineIntervalEnum.INTERVAL_1m
and the subscription never received data. Unwrap Enum members to their
value, as the REST and WebSocket API paths already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant