mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
fix(ui): invocation parsing for optional enum fields
For example: ```py my_field: Literal["foo", "bar"] | None = InputField(default=None) ``` Previously, this would cause a field parsing error and prevent the app from loading. Two fixes: - This type annotation and resultant schema are now parsed correctly - Error handling added to template building logic to prevent the hang at startup when an error does occur
This commit is contained in:
@@ -682,7 +682,7 @@ const buildEnumFieldInputTemplate: FieldInputTemplateBuilder<EnumFieldInputTempl
|
||||
if (filteredAnyOf.length !== 1 || !isSchemaObject(firstAnyOf)) {
|
||||
options = [];
|
||||
} else {
|
||||
options = firstAnyOf.enum ?? [];
|
||||
options = firstAnyOf.const ? [firstAnyOf.const] : (firstAnyOf.enum ?? []);
|
||||
}
|
||||
} else if (schemaObject.const) {
|
||||
options = [schemaObject.const];
|
||||
|
||||
@@ -161,8 +161,15 @@ export const parseSchema = (
|
||||
fieldType.batch = true;
|
||||
}
|
||||
|
||||
const fieldInputTemplate = buildFieldInputTemplate(property, propertyName, fieldType);
|
||||
inputsAccumulator[propertyName] = fieldInputTemplate;
|
||||
try {
|
||||
const fieldInputTemplate = buildFieldInputTemplate(property, propertyName, fieldType);
|
||||
inputsAccumulator[propertyName] = fieldInputTemplate;
|
||||
} catch {
|
||||
log.error(
|
||||
{ node: type, field: propertyName, schema: parseify(property) },
|
||||
'Problem building input field template'
|
||||
);
|
||||
}
|
||||
|
||||
return inputsAccumulator;
|
||||
},
|
||||
@@ -226,9 +233,16 @@ export const parseSchema = (
|
||||
fieldType.batch = true;
|
||||
}
|
||||
|
||||
const fieldOutputTemplate = buildFieldOutputTemplate(property, propertyName, fieldType);
|
||||
try {
|
||||
const fieldOutputTemplate = buildFieldOutputTemplate(property, propertyName, fieldType);
|
||||
outputsAccumulator[propertyName] = fieldOutputTemplate;
|
||||
} catch {
|
||||
log.error(
|
||||
{ node: type, field: propertyName, schema: parseify(property) },
|
||||
'Problem building output field template'
|
||||
);
|
||||
}
|
||||
|
||||
outputsAccumulator[propertyName] = fieldOutputTemplate;
|
||||
return outputsAccumulator;
|
||||
},
|
||||
{} as Record<string, FieldOutputTemplate>
|
||||
|
||||
Reference in New Issue
Block a user