fix: preserve empty Qwen prompts through connected switches

This commit is contained in:
LuqP2
2026-09-24 11:20:03 -03:00
parent 0a52b5ecd9
commit bf489626f0
2 changed files with 18 additions and 1 deletions
+12 -1
View File
@@ -31,8 +31,19 @@ def test_qwen_image_21_uses_distinct_conditioning_outputs():
assert data["negative"] == ""
assert "negative" not in missing
prompt["3"]["inputs"]["negative_prompt"] = ["7", 0]
prompt["3"]["inputs"]["negative_prompt"] = ["8", 0]
prompt["7"] = {"class_type": "String Literal", "inputs": {"string": ""}}
prompt["8"] = {"class_type": "ComfySwitchNode", "inputs": {
"switch": False, "on_false": ["7", 0], "on_true": ["9", 0],
}}
prompt["9"] = {"class_type": "PrimitiveStringMultiline", "inputs": {
"value": "inactive negative",
}}
data, missing = WorkflowExtractor(prompt).extract(save_node_id="6")
assert data["negative"] == ""
assert "negative" not in missing
prompt["3"]["inputs"]["negative_prompt"] = ["7", 0]
data, missing = WorkflowExtractor(prompt).extract(save_node_id="6")
assert data["negative"] == ""
assert "negative" not in missing
+6
View File
@@ -615,6 +615,12 @@ class WorkflowExtractor:
if class_type == "ConditioningZeroOut":
return ""
if class_type in ("PrimitiveStringMultiline", "String Literal"):
for key in ("value", "string", "text"):
value = self._get_literal_input(inputs, key)
if isinstance(value, str):
return value
if self._is_prompt_encoder(class_type):
return self._get_clip_text(node)