Skip to content

Commit 70fa3a2

Browse files
authored
Merge pull request #256 from pathsim/fix/empty-string-settings
Fix empty string settings causing validation errors in .pvm files
2 parents bd59e55 + 765f197 commit 70fa3a2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/lib/schema/fileOps.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export function createGraphFile(name?: string): GraphFile {
8080
// Clean params from all nodes (remove internal UI params, empty values, dead params)
8181
const cleanedNodes = nodes.map(n => cleanNodeForExport(n));
8282

83+
// Clean empty strings to null in settings so they round-trip correctly
84+
// (empty strings are used internally for placeholder display but shouldn't be persisted)
85+
const cleanedSettings = Object.fromEntries(
86+
Object.entries(settings).map(([k, v]) => [k, v === '' ? null : v])
87+
) as SimulationSettings;
88+
8389
return {
8490
version: GRAPH_FILE_VERSION,
8591
metadata: {
@@ -96,7 +102,7 @@ export function createGraphFile(name?: string): GraphFile {
96102
codeContext: {
97103
code
98104
},
99-
simulationSettings: settings
105+
simulationSettings: cleanedSettings
100106
};
101107
}
102108

0 commit comments

Comments
 (0)