A freshly added Switch fails the run instead of routing #29

Closed
opened 2026-09-17 10:17:38 +02:00 by morten-olsen · 0 comments
Owner

Context

Adding a Switch to a route and running the automation failed the step:

invalid_switch_condition: Switch rule 'Matching' failed:
Current record has no 'value' value.

BuiltInControlDescriptors seeded the Switch's first branch with the expression item.value == true. The editor copies schema defaults verbatim when an action is added, so every new Switch carried that condition, and any incoming record without a value key — which is most of them — failed the node outright rather than routing. The workflow broke until the author happened to replace the condition.

Swapping a condition to expression mode in the editor seeded the same placeholder.

Predates #12; typed conditions did not introduce it.

Scope

  • A newly added Switch must run. A placeholder that fails the step for ordinary records is worse than one that routes them.
  • The descriptor must not hand-write the condition wire format, so it cannot drift from the codec.

Resolution

Fixed on main in 096863b. The default is now the expression true: a new branch matches everything until the author narrows it, which is understandable and cannot fail. The descriptor calls encodeSwitchCondition rather than embedding the JSON shape by hand, so it stays the canonical encoded form rather than the legacy bare string.

Covered by SwitchDescriptorDefaultsTest, which asserts both that a default switch routes rather than failing and that the stored form is canonical. Verified on a Pixel 9 emulator by asking the app for its own descriptor default and running a workflow built from exactly that: the record routes to case:matching, fallback empty.

## Context Adding a Switch to a route and running the automation failed the step: ``` invalid_switch_condition: Switch rule 'Matching' failed: Current record has no 'value' value. ``` `BuiltInControlDescriptors` seeded the Switch's first branch with the expression `item.value == true`. The editor copies schema defaults verbatim when an action is added, so every new Switch carried that condition, and any incoming record without a `value` key — which is most of them — failed the node outright rather than routing. The workflow broke until the author happened to replace the condition. Swapping a condition to expression mode in the editor seeded the same placeholder. Predates #12; typed conditions did not introduce it. ## Scope - A newly added Switch must run. A placeholder that fails the step for ordinary records is worse than one that routes them. - The descriptor must not hand-write the condition wire format, so it cannot drift from the codec. ## Resolution Fixed on `main` in 096863b. The default is now the expression `true`: a new branch matches everything until the author narrows it, which is understandable and cannot fail. The descriptor calls `encodeSwitchCondition` rather than embedding the JSON shape by hand, so it stays the canonical encoded form rather than the legacy bare string. Covered by `SwitchDescriptorDefaultsTest`, which asserts both that a default switch routes rather than failing and that the stored form is canonical. Verified on a Pixel 9 emulator by asking the app for its own descriptor default and running a workflow built from exactly that: the record routes to `case:matching`, fallback empty.
morten-olsen 2026-09-17 10:17:38 +02:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No labels
bug
enhancement
feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
incubator/macros#29
No description provided.