mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-16 07:35:24 -05:00
fix(ui): handle form fields not existing on node on workflow load
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
isModelIdentifierFieldInputInstance,
|
||||
} from 'features/nodes/types/field';
|
||||
import type { WorkflowV3 } from 'features/nodes/types/workflow';
|
||||
import { buildNodeFieldElement, isWorkflowInvocationNode } from 'features/nodes/types/workflow';
|
||||
import { buildNodeFieldElement, isNodeFieldElement, isWorkflowInvocationNode } from 'features/nodes/types/workflow';
|
||||
import { getNeedsUpdate, updateNode } from 'features/nodes/util/node/nodeUpdate';
|
||||
import { t } from 'i18next';
|
||||
import type { JsonObject } from 'type-fest';
|
||||
@@ -252,5 +252,22 @@ export const validateWorkflow = async (
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of Object.values(_workflow.form.elements)) {
|
||||
if (!isNodeFieldElement(element)) {
|
||||
continue;
|
||||
}
|
||||
const { nodeId, fieldName } = element.data.fieldIdentifier;
|
||||
const node = nodes.filter(isWorkflowInvocationNode).find(({ id }) => id === nodeId);
|
||||
const field = node?.data.inputs[fieldName];
|
||||
if (!field) {
|
||||
// The form element field no longer exists on the node
|
||||
delete _workflow.form.elements[element.id];
|
||||
warnings.push({
|
||||
message: t('nodes.deletedMissingNodeFieldFormElement', { nodeId, fieldName }),
|
||||
data: { nodeId, fieldName },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return { workflow: _workflow, warnings };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user