Skip to content

Commit

Permalink
fix: fix webapp crash when datasetManager workspace option is an empt…
Browse files Browse the repository at this point in the history
…y object

When receiving an empty object (or missing fields) for the workspace option
[workspace].webApp.options.datasetManager, the webapp crashed with the error
'Object is not extensible'. This fix makes a shallow copy of the config
object to fix this error.
  • Loading branch information
csm-thu committed Mar 18, 2024
1 parent 041e824 commit bb0c6e2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const useDatasetOverview = () => {
}, [currentDataset?.id, datasetTwingraphQueriesResults]);

const datasetManagerConfig = useMemo(() => {
const config = workspaceData?.webApp?.options?.datasetManager ?? {};
// Make a shallow copy of config object to prevent error "Object is not extensible" when trying to set properties
const config = { ...workspaceData?.webApp?.options?.datasetManager };
if (config.categories == null) config.categories = [];
if (config.graphIndicators == null) config.graphIndicators = [];
if (config.queries == null) config.queries = [];
Expand Down

0 comments on commit bb0c6e2

Please sign in to comment.