Fix serialize missing ID response

This commit is contained in:
Abdul Khan 2026-06-02 19:04:02 -04:00
parent 0afb26e143
commit c0b6fd6ccb
3 changed files with 28 additions and 4 deletions

View file

@ -267,7 +267,7 @@ impl ApiService {
response_dom.transfer_within(child_ref, object_value);
} else {
msgpack(
return msgpack(
ErrorResponse::bad_request(format!("provided id {id} is not in the tree")),
StatusCode::BAD_REQUEST,
);

View file

@ -229,6 +229,16 @@ impl TestServeSession {
ids: &[Ref],
session_id: SessionId,
) -> Result<SerializeResponse, reqwest::Error> {
let body = self.post_api_serialize(ids, session_id)?.bytes()?;
Ok(deserialize_msgpack(&body).expect("Server returned malformed response"))
}
pub fn post_api_serialize(
&self,
ids: &[Ref],
session_id: SessionId,
) -> Result<reqwest::blocking::Response, reqwest::Error> {
let client = reqwest::blocking::Client::new();
let url = format!("http://localhost:{}/api/serialize", self.port);
let body = serialize_msgpack(&SerializeRequest {
@ -237,9 +247,7 @@ impl TestServeSession {
})
.unwrap();
let body = client.post(url).body(body).send()?.bytes()?;
Ok(deserialize_msgpack(&body).expect("Server returned malformed response"))
client.post(url).body(body).send()
}
}

View file

@ -1,6 +1,8 @@
use std::fs;
use insta::{assert_snapshot, assert_yaml_snapshot, with_settings};
use rbx_dom_weak::types::Ref;
use reqwest::StatusCode;
use tempfile::tempdir;
use crate::rojo_test::{
@ -659,6 +661,20 @@ fn meshpart_with_id() {
});
}
#[test]
fn serialize_missing_id() {
run_serve_test("empty", |session, _| {
let info = session.get_api_rojo().unwrap();
let missing_id = Ref::new();
let response = session
.post_api_serialize(&[missing_id], info.session_id)
.unwrap();
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
});
}
#[test]
fn forced_parent() {
run_serve_test("forced_parent", |session, mut redactions| {