From 960d28a8dc87e058a562854d68c595c1b6cc839e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 21 Oct 2025 10:37:14 -0700 Subject: [PATCH 1/2] Updating error frowarding from Transfer failures --- pkg/sip/protocol.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/sip/protocol.go b/pkg/sip/protocol.go index 05a3c69d..1c59dadf 100644 --- a/pkg/sip/protocol.go +++ b/pkg/sip/protocol.go @@ -375,7 +375,12 @@ func handleReferNotify(cseq uint32, status int, reason string, referCseq uint32, Code: livekit.SIPStatusCode(status), Status: reason, } - result = psrpc.NewErrorf(psrpc.Canceled, "call transfer failed: %w", st) + psrpcErrCode := psrpc.UpstreamServerError + if status < 500 || status >= 600 { + // Common 6xx codes: 603 Declined, 608 Rejected + psrpcErrCode = psrpc.UpstreamClientError + } + result = psrpc.NewErrorf(psrpcErrCode, "call transfer failed: %w", st) } select { case referDone <- result: @@ -413,6 +418,10 @@ func sipStatusForErrorCode(code psrpc.ErrorCode) sip.StatusCode { return sip.StatusServiceUnavailable case psrpc.Unauthenticated: return sip.StatusUnauthorized + case psrpc.UpstreamServerError: + return sip.StatusBadGateway + case psrpc.UpstreamClientError: + return sip.StatusTemporarilyUnavailable default: return sip.StatusInternalServerError } From 8b3c940abb6da06b73ae553204df5d98bb8b6d17 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 13 Nov 2025 11:37:43 -0800 Subject: [PATCH 2/2] Adding explicit call to psrpc.GetErrorCode(), only then overwriting it --- pkg/sip/protocol.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/sip/protocol.go b/pkg/sip/protocol.go index 1c59dadf..3a233fa2 100644 --- a/pkg/sip/protocol.go +++ b/pkg/sip/protocol.go @@ -375,12 +375,16 @@ func handleReferNotify(cseq uint32, status int, reason string, referCseq uint32, Code: livekit.SIPStatusCode(status), Status: reason, } - psrpcErrCode := psrpc.UpstreamServerError - if status < 500 || status >= 600 { - // Common 6xx codes: 603 Declined, 608 Rejected - psrpcErrCode = psrpc.UpstreamClientError + // Converts SIP status to GRPC via SIPStatus.GRPCStatus(), then converts to psrpc via ErrorCodeFromGRPC() + errorCode, _ := psrpc.GetErrorCode(st) + if errorCode == psrpc.Internal || errorCode == psrpc.Unavailable { + // Temporarily overwrite the code until we support a direct SIPStatus -> psrpc.ErrorCode conversion + errorCode = psrpc.UpstreamServerError + if status < 500 || status >= 600 { // Common 6xx codes: 603 Declined, 608 Rejected + errorCode = psrpc.UpstreamClientError + } } - result = psrpc.NewErrorf(psrpcErrCode, "call transfer failed: %w", st) + result = psrpc.NewErrorf(errorCode, "call transfer failed: %w", st) } select { case referDone <- result: