Repository navigation
fix(rtc): avoid mutable default and accept None in LocalParticipant.publish_data - #905
Open
NabiBukhsh-AI wants to merge 1 commit into
Open
NabiBukhsh-AI wants to merge 1 commit into
NabiBukhsh-AI wants to merge 1 commit into
Conversation
NabiBukhsh-AI
requested review from
changt,
cloudwebrtc,
lukasIO and
xianshijing-lk
as code owners
October 26, 2026 08:28
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LocalParticipant.publish_datadefined its destination parameter with a mutable default:This caused two issues:
ruff B006):destination_identities: List[str] = []is shared across calls.TypeErrorcrash onNone: Passingdestination_identities=None(common when forwarding an optional argument from caller code) causedreq.publish_data.destination_identities.extend(None)to raise:LocalParticipantthat takes destination identities (publish_dtmf,send_chat_message,stream_bytes,stream_text) defaults toNoneand conditionally extends the request withif destination_identities:.Changes
destination_identitiesdefault toNonewith typeOptional[Sequence[str]] = None, accepting tuples, lists, orNone.req.publish_data.destination_identitiesonly whendestination_identitiesis provided.Testing
Added unit tests in
tests/rtc/test_participant_publish_data.py:test_publish_data_parameter_default_is_none: verifiespublish_datasignature default isNone.test_publish_data_accepts_none_and_sequences: verifiespublish_datasucceeds when called with:destination_identities=None-> broadcastsdestination_identities=[]-> broadcasts["user1", "user2"])("user3", "user4"))uv run pytest tests/rtc/test_participant_publish_data.py -v -W error(2/2 passed)uv run ruff check livekit-rtc/livekit/rtc/participant.py tests/rtc/test_participant_publish_data.py(passed)uv run ruff format --check livekit-rtc/livekit/rtc/participant.py tests/rtc/test_participant_publish_data.py(passed)uv run mypy livekit-rtc/livekit/rtc/participant.py tests/rtc/test_participant_publish_data.py(0 issues)