From 372a422b3d86cb5c90ca5d31e1eee3a299fb971e Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 18 Feb 2026 05:32:46 -0600 Subject: [PATCH] Update SyncbackRequest structure and API protocol validation - Changed the `protocol_version` and `place_id` fields in the `SyncbackRequest` struct from `u64` to `f64` to accommodate Luau's numeric representation. - Updated the API's protocol version validation to compare the `syncback_request.protocol_version` as a `u64`, ensuring compatibility with the expected protocol version. - Enhanced type handling for `place_id` to maintain consistency in the syncback process. These changes improve the handling of numeric fields in syncback requests, aligning with the requirements of the Luau environment. --- src/web/api.rs | 8 +++++--- src/web/interface.rs | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/web/api.rs b/src/web/api.rs index c40f16cc..78301414 100644 --- a/src/web/api.rs +++ b/src/web/api.rs @@ -194,11 +194,12 @@ async fn handle_api_syncback( } }; - if syncback_request.protocol_version != PROTOCOL_VERSION { + let client_protocol = syncback_request.protocol_version as u64; + if client_protocol != PROTOCOL_VERSION { return msgpack( ErrorResponse::bad_request(format!( "Protocol version mismatch: expected {}, got {}", - PROTOCOL_VERSION, syncback_request.protocol_version + PROTOCOL_VERSION, client_protocol )), StatusCode::BAD_REQUEST, ); @@ -219,7 +220,8 @@ async fn handle_api_syncback( ); } - if let Some(place_id) = syncback_request.place_id { + if let Some(place_id_f64) = syncback_request.place_id { + let place_id = place_id_f64 as u64; if let Some(expected) = service.serve_session.serve_place_ids() { if !expected.contains(&place_id) { return msgpack( diff --git a/src/web/interface.rs b/src/web/interface.rs index 4fa7b796..2f0a27fb 100644 --- a/src/web/interface.rs +++ b/src/web/interface.rs @@ -37,12 +37,15 @@ pub struct ServiceChunk { } /// Incoming request from the plugin for live syncback. +/// Numeric fields use `f64` because Luau has no integer type -- all numbers +/// are IEEE 754 doubles, and large values (like place IDs) get encoded as +/// msgpack float64 which rmp_serde cannot coerce into u64. #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SyncbackRequest { - pub protocol_version: u64, + pub protocol_version: f64, pub server_version: String, - pub place_id: Option, + pub place_id: Option, pub services: Vec, }