fix(signal): read groupV2.id in envelope, fall back to legacy groupInfo#16260
Closed
teknium1 wants to merge 1 commit into
Closed
fix(signal): read groupV2.id in envelope, fall back to legacy groupInfo#16260teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
Port from nanocoai/nanoclaw#1962: modern Signal V2-only groups surface on dataMessage.groupV2.id, not groupInfo.groupId. signal-cli versions differ in which field they expose for V2 groups — some forward the underlying libsignal envelope verbatim (groupV2), others normalize everything into groupInfo. Without a groupV2 read, V2-only groups appear as DMs because groupInfo is undefined and the adapter misroutes them to the sender's DM session. Reads groupV2.id first, falls back to groupInfo.groupId. Also hardens chat_name extraction against non-dict groupInfo payloads (crashed with AttributeError under malformed envelopes). 6 new tests cover V2 routing, V1 legacy compatibility, V2-preferred precedence, no-group DM path, allowlist enforcement, and malformed payloads.
Contributor
Author
|
Closing in favor of #27051, which salvages this PR onto current main. One test-file conflict resolved (both main and the PR appended new test classes at EOF; both kept). 109/109 signal tests pass. |
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.
Port from qwibitai/nanoclaw#1962.
Summary
Modern Signal V2-only groups arrive with their group id on
dataMessage.groupV2.id, notdataMessage.groupInfo.groupId. signal-cli versions differ in which field they expose for V2 groups — some forward the underlying libsignal envelope verbatim (groupV2), others normalize everything intogroupInfo. Without a groupV2 read, V2-only groups appear as DMs becausegroupInfois undefined, and the adapter misroutes them to the sender's DM session.Changes
gateway/platforms/signal.py: readdataMessage.groupV2.idfirst, fall back todataMessage.groupInfo.groupIdfor V1 compatibility. Hardenchat_nameextraction against non-dictgroupInfopayloads (previously crashed withAttributeErrorunder malformed envelopes).tests/gateway/test_signal.py: 6 new tests (TestSignalGroupV2Routing) covering V2 routing, V1 legacy fallback, V2-preferred precedence when both fields are present, no-group DM path, allowlist enforcement on V2 ids, and malformed payload robustness.Adaptation notes
dataMessage.groupV2?.id ?? groupInfo?.groupIdisinstance(..., dict)guards since signal-cli JSON-RPC envelopes in the wild occasionally deliver unexpected shapes.SIGNAL_GROUP_ALLOWED_USERS) already runs ongroup_id, so it now correctly enforces against V2 ids as well.Validation
group:<v2-id>tests/gateway/test_signal.pyTest plan
scripts/run_tests.sh tests/gateway/test_signal.py— 73/73 passpy_compileclean on both filesSource PR: nanocoai/nanoclaw#1962 (V2 Signal adapter improvements — shipped as part of the NanoClaw v2 release).