return psrpc.FailedPrecondition for "participant client version does not support moving" error (#4736)

This commit is contained in:
Kuba Podgórski
2026-08-09 00:42:24 -07:00
committed by GitHub
parent 4e921aa1b6
commit 335990afa5
2 changed files with 28 additions and 2 deletions
+7 -2
View File
@@ -83,7 +83,7 @@ const (
)
var (
ErrMoveOldClientVersion = errors.New("participant client version does not support moving")
ErrMoveOldClientVersion = psrpc.NewErrorf(psrpc.FailedPrecondition, "participant client version does not support moving")
)
// -------------------------------------------------
@@ -4103,7 +4103,12 @@ func (p *ParticipantImpl) SupportsMoving() error {
}
if kind := p.Kind(); kind == livekit.ParticipantInfo_EGRESS || kind == livekit.ParticipantInfo_AGENT || p.params.UseOneShotSignallingMode {
return fmt.Errorf("%s participants cannot be moved, one-shot signaling mode: %t", kind.String(), p.params.UseOneShotSignallingMode)
return psrpc.NewErrorf(
psrpc.FailedPrecondition,
"%s participants cannot be moved, one-shot signaling mode: %t",
kind.String(),
p.params.UseOneShotSignallingMode,
)
}
return nil
+21
View File
@@ -22,6 +22,7 @@ import (
"github.com/pion/webrtc/v4"
"github.com/stretchr/testify/require"
"github.com/twitchtv/twirp"
"go.uber.org/atomic"
"google.golang.org/protobuf/proto"
@@ -77,6 +78,26 @@ func TestIsReady(t *testing.T) {
}
}
func TestSupportsMoving(t *testing.T) {
t.Run("current protocol version", func(t *testing.T) {
p := newParticipantForTestWithOpts("test", &participantOpts{protocolVersion: types.CurrentProtocol})
require.NoError(t, p.SupportsMoving())
})
// a move rejected because of what the participant is cannot be retried into working, but it is
// still a caller error, so it has to surface as a 4xx rather than a 500
t.Run("client version that cannot be moved", func(t *testing.T) {
p := newParticipantForTestWithOpts("test", &participantOpts{protocolVersion: 6})
err := p.SupportsMoving()
require.ErrorIs(t, err, ErrMoveOldClientVersion)
var twirpErr twirp.Error
require.ErrorAs(t, err, &twirpErr)
require.Equal(t, twirp.FailedPrecondition, twirpErr.Code())
})
}
func TestTrackPublishing(t *testing.T) {
t.Run("should send the correct events", func(t *testing.T) {
p := newParticipantForTest("test")