70 lines
3.2 KiB
Plaintext
70 lines
3.2 KiB
Plaintext
--- 0.21.1:validate_inputs
|
|
+++ 8010:validate_inputs
|
|
@@ -35,7 +35,17 @@
|
|
if issubclass(obj_class, _ComfyNodeInternal):
|
|
obj_class: _io._ComfyNodeBaseInternal
|
|
class_inputs = obj_class.INPUT_TYPES()
|
|
- class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
|
+ try:
|
|
+ class_inputs, _, v3_data = _io.get_finalized_class_inputs(class_inputs, inputs)
|
|
+ except _io.DynamicInputError as ex:
|
|
+ errors.append({
|
|
+ "type": "invalid_dynamic_input",
|
|
+ "message": "Invalid dynamic input",
|
|
+ "details": str(ex),
|
|
+ "extra_info": {"input_name": ex.input_name},
|
|
+ })
|
|
+ validated[unique_id] = (False, errors, unique_id)
|
|
+ return validated[unique_id]
|
|
validate_function_name = "validate_inputs"
|
|
validate_function = first_real_override(obj_class, validate_function_name)
|
|
else:
|
|
@@ -236,29 +246,35 @@
|
|
|
|
if len(validate_function_inputs) > 0 or validate_has_kwargs:
|
|
input_data_all, _, v3_data = get_input_data(inputs, obj_class, unique_id)
|
|
+ dynamic_paths = v3_data.get("dynamic_paths", {})
|
|
+ if not validate_has_kwargs:
|
|
+ dynamic_paths = {key: path for key, path in dynamic_paths.items() if path.split(".")[0] in validate_function_inputs}
|
|
+ v3_data = v3_data | {
|
|
+ "dynamic_paths": dynamic_paths,
|
|
+ "list_paths": {path for path in v3_data.get("list_paths", set()) if path.split(".")[0] in validate_function_inputs},
|
|
+ }
|
|
input_filtered = {}
|
|
for x in input_data_all:
|
|
- if x in validate_function_inputs or validate_has_kwargs:
|
|
+ input_name = dynamic_paths[x].split(".")[0] if x in dynamic_paths else x
|
|
+ if input_name in validate_function_inputs or validate_has_kwargs:
|
|
input_filtered[x] = input_data_all[x]
|
|
if 'input_types' in validate_function_inputs:
|
|
input_filtered['input_types'] = [received_types]
|
|
|
|
ret = await _async_map_node_over_list(prompt_id, unique_id, obj_class, input_filtered, validate_function_name, v3_data=v3_data)
|
|
ret = await resolve_map_node_over_list_results(ret)
|
|
- for x in input_filtered:
|
|
+ for x in input_filtered or (None,):
|
|
for i, r in enumerate(ret):
|
|
if r is not True and not isinstance(r, ExecutionBlocker):
|
|
- details = f"{x}"
|
|
+ details = x if x is not None else ""
|
|
if r is not False:
|
|
- details += f" - {str(r)}"
|
|
+ details = f"{x} - {r}" if x is not None else str(r)
|
|
|
|
error = {
|
|
"type": "custom_validation_failed",
|
|
"message": "Custom validation failed for node",
|
|
"details": details,
|
|
- "extra_info": {
|
|
- "input_name": x,
|
|
- }
|
|
+ "extra_info": {"input_name": x} if x is not None else {},
|
|
}
|
|
errors.append(error)
|
|
continue
|
|
@@ -272,4 +288,4 @@
|
|
)
|
|
|
|
validated[unique_id] = ret
|
|
- return ret+ return ret
|