From 765f19769434e80d8b386d5ea895016318b64958 Mon Sep 17 00:00:00 2001 From: Milan Rother Date: Tue, 17 Feb 2026 14:52:23 +0100 Subject: [PATCH] Fix empty string settings causing validation errors in .pvm files --- src/lib/schema/fileOps.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/schema/fileOps.ts b/src/lib/schema/fileOps.ts index 9c6d7b89..597e7d46 100644 --- a/src/lib/schema/fileOps.ts +++ b/src/lib/schema/fileOps.ts @@ -80,6 +80,12 @@ export function createGraphFile(name?: string): GraphFile { // Clean params from all nodes (remove internal UI params, empty values, dead params) const cleanedNodes = nodes.map(n => cleanNodeForExport(n)); + // Clean empty strings to null in settings so they round-trip correctly + // (empty strings are used internally for placeholder display but shouldn't be persisted) + const cleanedSettings = Object.fromEntries( + Object.entries(settings).map(([k, v]) => [k, v === '' ? null : v]) + ) as SimulationSettings; + return { version: GRAPH_FILE_VERSION, metadata: { @@ -96,7 +102,7 @@ export function createGraphFile(name?: string): GraphFile { codeContext: { code }, - simulationSettings: settings + simulationSettings: cleanedSettings }; }