From 75050bc088678a8c424bd67ac98ef5180c8dfaa7 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Mon, 31 Aug 2026 14:54:32 +0700 Subject: [PATCH] fix(gateway): use rtc_server_id-1 as watch DAVE MLS channelId (WrongGroupId) Live log (14:52) showed the stream-watch flow reaching STREAM_CREATE + STREAM_SERVER_UPDATE but then DAVE processProposals threw 'ValidationError(WrongGroupId)' -- the Davey MLS session derived the wrong group because connectionOptions.channelId was the guild voice channel id. Per Discord-RE StreamConnection.daveChannelId = BigInt(serverId)-1n, the stream-watch DAVE MLS group is keyed to rtc_server_id-1, not the vc channel. Fix: pass BigInt(serverId)-1n as channelId to the watch Networking. This error also surface as an uncaughtException that crashed the gateway (systemd restarted it). Correct channel id prevents it at the root. --- .../voice-recording/streamWatchReceiver.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/discord-gateway/src/modules/voice-recording/streamWatchReceiver.ts b/services/discord-gateway/src/modules/voice-recording/streamWatchReceiver.ts index 87899353..18c66c5c 100644 --- a/services/discord-gateway/src/modules/voice-recording/streamWatchReceiver.ts +++ b/services/discord-gateway/src/modules/voice-recording/streamWatchReceiver.ts @@ -224,6 +224,20 @@ function connectWatch( "Opening DAVE Networking to watch RTC", ); + // CRITICAL: for a STREAM-WATCH RTC the DAVE MLS group is keyed to + // `rtc_server_id - 1` (see Discord-RE StreamConnection.daveChannelId = + // BigInt(serverId)-1n), NOT the guild voice channel id. Passing the guild + // voice channel id as `connectionOptions.channelId` makes the Davey session + // derive the wrong MLS group → "WrongGroupId" on proposals → never Ready. + // `serverId` stays the rtc_server_id (used in the voice identify server_id). + const daveChannelId = (() => { + try { + return (BigInt(serverId) - 1n).toString(); + } catch { + return channelId; // fallback: non-numeric serverId — use channel id + } + })(); + const net = new Networking( { endpoint, @@ -231,7 +245,7 @@ function connectWatch( userId: botId, sessionId: sessionId ?? "none", token, - channelId, + channelId: daveChannelId, }, { daveEncryption: true }, );