Validate supplied components in imported player data

An import with `crafting_queue: {}` passed the schema and broke the
next restore in deserialize_crafting_queue. The import schema now
checks the members module/serialize.lua reads from the crafting queue,
quick bar, personal logistic slots and character stats, while still
allowing a component to be left out.

Character stats missing from the data are left as they are instead of
being set to nil.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-17 20:18:51 +00:00
1 parent 5634651de1
commit c06555c5da
4 files changed
+137 -18

No files matched your search

+17
View File
@@ -208,6 +208,23 @@ describe("player_sync controller", function() {
await assert.rejects(set("stored", playerData("stored", 3)), acquiredError);
assert.equal((await saved()).get("stored").generation, 3);
});
it("should keep the stored data when an import fails validation", async function() {
// The link validates requests before the handler runs
const fromJSON = lib.Link.requestFromJSON(msg.SetPlayerDataRequest, "SetPlayerDataRequest");
async function setJSON(name, data) {
const request = fromJSON({ playerName: name, playerData: data });
return await handler(msg.SetPlayerDataRequest)(request);
}
await release("stored");
await setJSON("stored", playerData("stored", 0));
const before = (await saved()).get("stored");
assert.equal(before.epoch, 1);
await assert.rejects(
setJSON("stored", playerData("stored", 0, { crafting_queue: {} })),
{ message: "Request SetPlayerDataRequest failed validation" },
);
assert.deepEqual((await saved()).get("stored"), before);
});
});
describe("DeletePlayerDataRequest", function() {