是否有值丨检测
Did that node actually produce anything? This answers in three flavors
- source
- 布尔
- 字符串
- 整数
Optional branches in ComfyUI fail silently. Wire up a fallback, leave an input unconnected, and the graph just... does nothing, and you can't tell whether the empty result is because the branch was never meant to fire or because it quietly broke. HasValue is the diagnostic-adjacent utility that turns "is there data here?" into a signal you can route on. It accepts anything on its source input - the wildcard * type, so it doesn't care whether you're checking a string, an image, or a list - and answers with the same truth in three formats.
It's part of ComfyUI-QING's data-tools family (display name 是否有值丨检测). This is classic plumbing-layer thinking: the node's whole job is presence detection, the thing the KB's node-plumbing essay calls first-non-null logic. If you've used rgthree's Any Switch or any fallback switch, you already know the pattern - this is the "check the branch actually has a value" half of it, made explicit.
How it works. The implementation treats the input as a list (INPUT_IS_LIST = True) and asks: does any of the values "exist"? The _value_exists check treats None, empty strings, and empty collections as no-value, so a real string or a real tensor counts as present. One nuance worth knowing: it answers "any," not "all" - if you feed it a batch where only some entries are populated, it still reports true. For strict "every slot is filled" checks you'd need to verify upstream.
The inputs and outputs that matter.
source- optional,*typed. Connect anything. Leave it unwired and it reports "no value," which is its own kind of useful in a fallback chain.- Outputs: 布尔 (BOOLEAN
true/false), 字符串 (STRING), and 整数 (INT) - same answer, three types.
Here's the quirk that will trip you up: the string output is "1.0" when there's a value and "0.0" when there isn't. It's a float-formatted string, not "true"/"false". If you're feeding the string into a text router or a filename, expect the number format. The boolean and integer outputs are the clean ones - use 布尔 to drive a switch or condition router, and 整数 when you want a numeric 1/0 (handy for multiplying a branch in or out).
How to install. ComfyUI-QING is a one-pack install - search "ComfyUI-QING" in ComfyUI Manager, or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/GAO-SHIQING/ComfyUI-QING
cd ComfyUI-QING
python install_dependencies.py
Restart after installing. Watch for the README's typo'd clone URL (GAOSHI-QING, missing the H) - use the URL above or Manager.
Troubleshooting. Since source is optional and *-typed, the most common beginner mistake is expecting it to do something when nothing is connected - it reports false (0.0), which is correct behavior. The real debugging move is to verify what upstream is actually sending: a node that outputs an empty string will register as no-value, while an all-black image still counts as "present" because tensors aren't empty. If your downstream router keeps choosing the wrong branch, check whether upstream emits an empty-but-not-None value - that's the edge case where "has a value" and "has a useful value" disagree.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| sourceopt | * | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 布尔 | BOOLEAN | — |
| 字符串 | STRING | — |
| 整数 | INT | — |