Skip to content

Commit

Permalink
safeguard against empty or 1 len meta
Browse files Browse the repository at this point in the history
  • Loading branch information
x37v committed May 7, 2024
1 parent 2442f4f commit 5a9d719
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/actions/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ const serializeSetMeta = (nodes: GraphNodeRecord[]): string => {
};

const deserializeSetMeta = (metaString: string): OSCQuerySetMeta => {
try {
return JSON.parse(metaString || '{ "nodes": {} }') as OSCQuerySetMeta;
} catch (err) {
console.warn(`Failed to parse Set Meta when creating new node: ${err.message}`);
return { nodes: {} };
// I don't know why we're getting strings of length 1 but, they can't be valid JSON anyway
if (metaString && metaString.length > 1) {
try {
return JSON.parse(metaString) as OSCQuerySetMeta;
} catch (err) {
console.warn(`Failed to parse Set Meta when creating new node: ${err.message}`);
}
}
return { nodes: {} };
};

export enum GraphActionType {
Expand Down

0 comments on commit 5a9d719

Please sign in to comment.