Skip to content

fix: match WebSocket wildcard topics on the exact channel - #18

Draft
chipkent wants to merge 1 commit into
masterfrom
fix/ws-wildcard-channel
Draft

chipkent wants to merge 1 commit into
masterfrom
fix/ws-wildcard-channel

Conversation

@chipkent

Copy link
Copy Markdown
Owner

Preview only. This is a draft in the fork showing the exact text of the PR planned for massive-com/client-python. It will be closed, not merged, once the upstream PR is opened.

Fixes #<issue: F1b>

Subscribing to a wildcard such as A.* drops the other subscribed topics on the same channel. The match used t.startswith(channel), so:

  • subscribe("A.*") also dropped AM.AAPL, and likewise for XA.*/XAS.* and C.*/CA.*/CAS.*;
  • calling subscribe("A.*") a second time unsubscribed A.*, because the wildcard matched itself.

This PR compares the channel exactly and skips the wildcard itself, in subscribe() and unsubscribe(). Nothing else changes: as before, only topics already sent are checked.

client.subs = {"A.MSFT", "AM.AAPL"}  # already sent
client.subscribe("A.*")
client.scheduled_subs  # before: {"A.*"}  now: {"A.*", "AM.AAPL"}

Tests

  • New test_websocket/test_wildcard.py: three unit tests that set subs directly, with no server. All three fail on master.
  • make test and make lint pass on Python 3.10 and 3.14.

Independent of the other PRs.

Subscribing to a wildcard such as A.* drops the other subscribed topics
on that channel. The match used t.startswith(channel), so it also
dropped topics on every channel whose name starts with the same
letters: subscribe("A.*") unsubscribed AM.AAPL. It also matched the
wildcard itself, so subscribing to A.* a second time unsubscribed it.

Compare the channel exactly, and skip the wildcard being subscribed.
unsubscribe() used the same match and gets the same fix. As before,
only topics already sent are checked.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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