fix: expose SIP status codes in transfer and participant errors#622
fix: expose SIP status codes in transfer and participant errors#622yusuf-eren wants to merge 4 commits intolivekit:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 2d9276c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| transferTo: string, | ||
| opts?: TransferSipParticipantOptions, | ||
| ): Promise<void> { | ||
| ): Promise<string> { |
There was a problem hiding this comment.
🟡 transferSipParticipant declares Promise<string> but returns a parsed JSON object at runtime
The return type of transferSipParticipant was changed from Promise<void> to Promise<string>, and it now returns the raw result of this.rpc.request(). However, TwirpRpc.request() (the actual implementation at packages/livekit-server-sdk/src/TwirpRPC.ts:87) returns Promise<any> — specifically a parsed JSON object that has been run through camelcaseKeys (TwirpRPC.ts:134-135). The TransferSIPParticipant RPC endpoint returns an empty protobuf response, which serializes as {} in JSON.
Root Cause
The Rpc interface at TwirpRPC.ts:26 declares Promise<string>, but the actual TwirpRpc.request() implementation at TwirpRPC.ts:87 returns Promise<any> (a parsed and camelCased JSON object). All other callers of this.rpc.request() (e.g., createSipParticipant at line 765) pass the result through SomeType.fromJson(data, ...), which properly converts it. But transferSipParticipant now directly returns the raw result to the caller.
Callers of transferSipParticipant will receive an empty object {} typed as string. Any string operations on the result (e.g., .length, .startsWith(), comparisons) would produce incorrect results silently.
Impact: Misleading return type causes runtime type mismatch. Callers that treat the result as a string will encounter unexpected behavior.
Prompt for agents
In packages/livekit-server-sdk/src/SipClient.ts, the transferSipParticipant method at line 776-800 should either: (1) Keep the return type as Promise<void> (reverting the change) since the transfer RPC response is empty and the purpose of this PR is to expose SIP status codes via TwirpError (which already works on the error path), OR (2) If a meaningful response is expected, parse it with an appropriate protobuf response type (e.g. a TransferSIPParticipantResponse.fromJson(data)) similar to how createSipParticipant at line 765 does it. The current approach of returning the raw rpc.request() result typed as string is incorrect since the actual runtime value is a parsed JSON object ({}).
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes #606