From a06ef394ca93e4ee8565f45de3515a101269b59e Mon Sep 17 00:00:00 2001 From: Chip Kent <5250374+chipkent@users.noreply.github.com> Date: Fri, 23 Oct 2026 17:06:54 -0600 Subject: [PATCH] fix: log the topic for an invalid subscription _parse_subscription called logger.warning("invalid subscription:", s), passing the topic as a format argument with no placeholder. Logging printed "--- Logging error ---" and a traceback instead of the warning, and the rejected topic was never shown. Use a %s placeholder so the warning reads "invalid subscription: ", and add a test to test_status.py that goes through subscribe(). --- massive/websocket/__init__.py | 2 +- test_websocket/test_status.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/massive/websocket/__init__.py b/massive/websocket/__init__.py index 7463b4cb..da11c040 100644 --- a/massive/websocket/__init__.py +++ b/massive/websocket/__init__.py @@ -265,7 +265,7 @@ def _parse_subscription(s: str): s = s.strip() split = s.split(".", 1) # Split at the first period if len(split) != 2: - logger.warning("invalid subscription:", s) + logger.warning("invalid subscription: %s", s) return [None, None] return split diff --git a/test_websocket/test_status.py b/test_websocket/test_status.py index d333c9c8..c2bf2666 100644 --- a/test_websocket/test_status.py +++ b/test_websocket/test_status.py @@ -95,3 +95,13 @@ async def test_auth_reply_status_is_logged(self): "Maximum number of websocket connections exceeded." ], ) + + async def test_invalid_subscription_is_logged(self): + # a topic without a channel prefix is skipped with a warning + c = WebSocketClient(api_key="") + with self.assertLogs("WebSocketClient", level="WARNING") as logs: + c.subscribe("AAPL") + self.assertEqual( + logs.output, ["WARNING:WebSocketClient:invalid subscription: AAPL"] + ) + self.assertEqual(c.scheduled_subs, set())