Fail closed on invalid display mappings

This commit is contained in:
2026-07-02 16:35:19 +02:00
parent 7e4e85a0bd
commit 2c9452ae67
2 changed files with 55 additions and 1 deletions
@@ -2354,6 +2354,58 @@ NODE_DISPLAY_NAME_MAPPINGS = build_displays()
self.assertEqual({}, result["nodes"])
self.assertEqual("no_static_nodes", result["pack"]["status"])
def test_non_string_display_mapping_value_skips_node(self):
source = '''
class NonStringDisplayValueNode:
RETURN_TYPES = ("IMAGE",)
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image": ("IMAGE",),
},
}
NODE_CLASS_MAPPINGS = {
"NonStringDisplayValueNode": NonStringDisplayValueNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"NonStringDisplayValueNode": 123,
}
'''
result = self._extract_source(source, "non-string-display-value-pack")
self.assertEqual({}, result["nodes"])
self.assertEqual("no_static_nodes", result["pack"]["status"])
def test_non_string_display_mapping_key_skips_node(self):
source = '''
class NonStringDisplayKeyNode:
RETURN_TYPES = ("IMAGE",)
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image": ("IMAGE",),
},
}
NODE_CLASS_MAPPINGS = {
"NonStringDisplayKeyNode": NonStringDisplayKeyNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
123: "Non String Display Key",
}
'''
result = self._extract_source(source, "non-string-display-key-pack")
self.assertEqual({}, result["nodes"])
self.assertEqual("no_static_nodes", result["pack"]["status"])
def test_input_types_with_dynamic_control_flow_is_skipped(self):
source = '''
def something():
+3 -1
View File
@@ -1074,7 +1074,9 @@ def _display_mappings(tree):
return {}
if displays is _INVALID:
return _INVALID
return {str(k): str(v) for k, v in displays.items()}
if not all(isinstance(key, str) and isinstance(value, str) for key, value in displays.items()):
return _INVALID
return displays
def _signature_from_class(node_type, cls, display, pack_meta, class_env, input_env):