Fail closed on invalid node mapping keys
This commit is contained in:
@@ -1869,6 +1869,29 @@ KEY = "Wrong"
|
|||||||
self.assertEqual(["IMAGE"], result["nodes"]["Original"]["outputs"])
|
self.assertEqual(["IMAGE"], result["nodes"]["Original"]["outputs"])
|
||||||
self.assertEqual("ok", result["pack"]["status"])
|
self.assertEqual("ok", result["pack"]["status"])
|
||||||
|
|
||||||
|
def test_non_string_node_mapping_key_skips_node(self):
|
||||||
|
source = '''
|
||||||
|
class NonStringMappingKeyNode:
|
||||||
|
RETURN_TYPES = ("IMAGE",)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(cls):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"image": ("IMAGE",),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
123: NonStringMappingKeyNode,
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
result = self._extract_source(source, "non-string-mapping-key-pack")
|
||||||
|
|
||||||
|
self.assertEqual({}, result["nodes"])
|
||||||
|
self.assertEqual("no_static_nodes", result["pack"]["status"])
|
||||||
|
|
||||||
def test_module_class_return_types_patch_after_mapping_skips_node(self):
|
def test_module_class_return_types_patch_after_mapping_skips_node(self):
|
||||||
source = '''
|
source = '''
|
||||||
class PatchedReturnTypesNode:
|
class PatchedReturnTypesNode:
|
||||||
|
|||||||
@@ -1060,7 +1060,9 @@ def _node_class_mappings(tree):
|
|||||||
_mapping_value_binding,
|
_mapping_value_binding,
|
||||||
_node_mapping_invalidated_by_names,
|
_node_mapping_invalidated_by_names,
|
||||||
)
|
)
|
||||||
return {str(node_type): binding for node_type, (_class_name, binding) in mappings.items() if node_type}
|
if not all(isinstance(node_type, str) for node_type in mappings):
|
||||||
|
return {}
|
||||||
|
return {node_type: binding for node_type, (_class_name, binding) in mappings.items() if node_type}
|
||||||
|
|
||||||
|
|
||||||
def _display_mappings(tree):
|
def _display_mappings(tree):
|
||||||
|
|||||||
Reference in New Issue
Block a user