From bf489626f0f6227164e4e59c6e77783ebd68b74d Mon Sep 17 00:00:00 2001 From: LuqP2 Date: Thu, 24 Sep 2026 11:20:03 -0300 Subject: [PATCH] fix: preserve empty Qwen prompts through connected switches --- tests/test_workflow_extractor.py | 13 ++++++++++++- workflow_extractor.py | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_workflow_extractor.py b/tests/test_workflow_extractor.py index f61f1e4..8499cc4 100644 --- a/tests/test_workflow_extractor.py +++ b/tests/test_workflow_extractor.py @@ -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 diff --git a/workflow_extractor.py b/workflow_extractor.py index 9ac3d86..8395504 100644 --- a/workflow_extractor.py +++ b/workflow_extractor.py @@ -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)