A switch compares its value; it does not evaluate it
Despite the parameter's name, a switch gateway runs no expression engine. The value is matched against each branch as it stands.
The rule
- A switch gateway does not evaluate its
expression. - The value is compared unchanged against each branch's
valuein declaration order, with no coercion: a branch matches only where the two are of the same type as well as equal. - The first matching branch is the sole active branch, and its name is what the gateway reports as active.
- Where no branch matches, the branch named by
default_branchis active; where no branch matches and no usable default is named, the node fails.
What it means
The parameter is named expression, but no expression engine ever sees it. A
value that happens to look like a query — a JSONPath-shaped string, say — is
still just a string, compared for exact equality against each branch's own
value in the order the branches are declared. There is no coercion either: the
comparison also requires the same type, so a value and a branch that would be
equal after a type conversion still miss each other.
Only the first branch to match becomes active, and its declared name is what the gateway reports. Nothing matching falls through to the configured default branch; nothing matching and no usable default fails the node outright.
Example
A value shaped exactly like a JSONPath query, matched against a branch whose own configured value is that same literal string:
{
"expression": "$.user.role",
"default_branch": "default",
"branches": [
{ "name": "Admin", "value": "admin" },
{ "name": "Literal", "value": "$.user.role" }
]
}["Literal"]The same strictness rules out a type match that a looser comparison would allow:
{ "expression": "1", "default_branch": "Fallback", "branches": [{ "name": "IntOne", "value": 1 }] }["Fallback"]"1" and 1 are equal after conversion but not of the same type, so the
comparison misses and the configured default branch, Fallback, is what
activates.