Skip to content

Commit 83fa5f2

Browse files
authored
Address typo in parsing rpc server version (#1268)
The version check was incorrect - it looks like this has been broken and not actually properly validating that the server vefsion is 1.8.0 or greater. ### Breaking changes No breaking changes. ### MSRV N/A ### Testing Added a test to prevent another regression like this.
1 parent 62359c3 commit 83fa5f2

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
livekit: patch
3+
livekit-ffi: patch
4+
---
5+
6+
Address typo in parsing rpc server version - #1268 (@1egoman)

livekit/src/room/rpc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl RpcTransport for SessionTransport {
100100
.signal_client()
101101
.join_response()
102102
.server_info
103-
.and_then(|info| info.version.is_empty().then(|| info.version))
103+
.and_then(|info| (!info.version.is_empty()).then(|| info.version))
104104
}
105105
}
106106

livekit/src/room/rpc/tests.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ impl MockTransport {
6060
self
6161
}
6262

63+
fn with_server_version(mut self, version: Option<&str>) -> Self {
64+
self.server_ver = version.map(str::to_string);
65+
self
66+
}
67+
6368
/// Wait until at least one packet has been sent.
6469
async fn wait_for_packet(&self) {
6570
self.packet_sent.notified().await;
@@ -745,6 +750,34 @@ async fn test_v2_response_stream_resolves_caller() {
745750
assert_eq!(result.unwrap(), "stream-result");
746751
}
747752

753+
// =========================================================================
754+
// Server version check tests
755+
// =========================================================================
756+
757+
/// A server older than the minimum required version is rejected with
758+
/// UNSUPPORTED_SERVER before any request is sent.
759+
#[tokio::test]
760+
async fn test_server_below_minimum_version_rejected() {
761+
let client = RpcClientManager::new();
762+
let transport = MockTransport::new()
763+
.with_remote_protocol("dest", CLIENT_PROTOCOL_DATA_STREAM_RPC)
764+
.with_server_version(Some("1.7.9"));
765+
766+
let result = client
767+
.perform_rpc(
768+
PerformRpcData::new("dest", "greet")
769+
.with_payload("hi")
770+
.with_response_timeout(Duration::from_millis(50)),
771+
&transport,
772+
)
773+
.await;
774+
775+
let err = result.unwrap_err();
776+
assert_eq!(err.code, RpcErrorCode::UnsupportedServer as u32);
777+
assert!(transport.packets().is_empty());
778+
assert!(transport.texts().is_empty());
779+
}
780+
748781
/// Verify unregistered method returns UNSUPPORTED_METHOD error via v2 path.
749782
#[tokio::test]
750783
async fn test_v2_handler_unsupported_method() {

0 commit comments

Comments
 (0)