Skip to content

Conversation

@alexlivekit
Copy link
Contributor

Today we return psrpc.Canceled, which then gets translated to HTTP code 500. This can be quite problematic when we get return codes like: 480 Temporarily Unavailable, 603 Decline, 486 Busy Here, 404 Not Found. These are either user errors, outright rejections, or numbers incapable of handling two simultaneous calls.

This change will get us to emit UpstreamServerError and UpstreamClientError as responses, that would translate to HTTP codes 502 and 424 respectively, correctly identifying failures in resources upstream of the sip server.

@alexlivekit alexlivekit requested a review from a team as a code owner October 24, 2025 19:32
Status: reason,
}
result = psrpc.NewErrorf(psrpc.Canceled, "call transfer failed: %w", st)
psrpcErrCode := psrpc.UpstreamServerError
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going over twirp, this will still produce a bad error, due to Twirp not having the appropriate response codes to convert this to. However, data indicates the vast majority of errors are not 5XX errors and are going to be UpstreamClientError. which would convert to twirp.InvalidArgument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't related to Twirp, but our error code mapping in psrpc? why don't we just map it to the right thing there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This completely ignores the existing mapping to gRPC/PSRPC/Twirp error codes that we have. Maybe we should update the mapping there instead?

@alexlivekit alexlivekit requested a review from davidzhao October 24, 2025 20:49
Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we also handle other common incorrect error mapping? for example, CreateSIPParticipant is also throwing some of these errors

Status: reason,
}
result = psrpc.NewErrorf(psrpc.Canceled, "call transfer failed: %w", st)
psrpcErrCode := psrpc.UpstreamServerError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't related to Twirp, but our error code mapping in psrpc? why don't we just map it to the right thing there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants