From c856fab7d1eedcc3f12e73fb68ea3db8a17a35e2 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:15:46 +1100 Subject: [PATCH] fix(ui): load default workflows mutation error Loading default workflows sometimes requires we mutate the workflow object in order to change the category or ID of the workflow. This happens in `invokeai/frontend/web/src/features/nodes/util/workflow/validateWorkflow.ts` The data we get back from the query hooks is frozen and sealed by redux, because they are part of redux state. We need to clone the workflow before operating on it. It's not clear how this ever worked in the past, because redux state has always been frozen and sealed. --- .../web/src/features/nodes/util/workflow/migrations.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/features/nodes/util/workflow/migrations.ts b/invokeai/frontend/web/src/features/nodes/util/workflow/migrations.ts index a023c96ba9..559c524808 100644 --- a/invokeai/frontend/web/src/features/nodes/util/workflow/migrations.ts +++ b/invokeai/frontend/web/src/features/nodes/util/workflow/migrations.ts @@ -11,7 +11,7 @@ import { zWorkflowV2 } from 'features/nodes/types/v2/workflow'; import type { WorkflowV3 } from 'features/nodes/types/workflow'; import { zWorkflowV3 } from 'features/nodes/types/workflow'; import { t } from 'i18next'; -import { forEach } from 'lodash-es'; +import { cloneDeep, forEach } from 'lodash-es'; import { z } from 'zod'; /** @@ -89,7 +89,7 @@ export const parseAndMigrateWorkflow = (data: unknown): WorkflowV3 => { throw new WorkflowVersionError(t('nodes.unableToGetWorkflowVersion')); } - let workflow = data as WorkflowV1 | WorkflowV2 | WorkflowV3; + let workflow = cloneDeep(data) as WorkflowV1 | WorkflowV2 | WorkflowV3; if (workflow.meta.version === '1.0.0') { const v1 = zWorkflowV1.parse(workflow);