Repository navigation
fix(workflows): compare contact.email case-insensitively in conditions - #512
theluckystrike wants to merge 1 commit into
Conversation
Segment filters match contact.email without regard to case, and the operator rules in @plunk/shared say workflow conditions must behave the same way. The CONDITION step compared it with === and includes(), so "equals Jane@Example.com" or "contains @Example.com" took the wrong branch for a contact stored as jane@example.com. Lowercase both sides for contact.email before evaluating equals, notEquals, contains and notContains, in binary and multi-branch mode. Fields under data.* stay exact.
|
If I get it correctly then this change is purely to prevent "typos" when setting up a condition, right? Plunk already normalises all emails to lowercase on all input paths. |
|
Yes, that's right. Stored emails are already lowercase, so only the value typed into the condition matters. Today "equals Jane@Example.com" or "contains @Example.com" never matches, because the stored side is jane@example.com. Segments already accept those values, since SegmentService uses mode: 'insensitive' for equals and contains (SegmentService.ts lines 1033 to 1039). This PR makes the workflow condition behave the same way, so a value that works in a segment filter also works in a workflow. If you would rather lowercase the condition value when the workflow is saved, I can switch the PR to that. If it is not worth it, closing it is fine too. |
Description
Segment filters match contact.email without regard to case. The operator rules in packages/shared/src/operators.ts say workflow conditions must behave the same way.
The CONDITION step compared contact.email with === and includes(). So a condition like "contact.email equals Jane@Example.com" or "contains @Example.com" took the wrong branch for a contact stored as jane@example.com.
This change lowercases both sides for contact.email before evaluating equals, notEquals, contains and notContains. It applies to binary and multi-branch conditions. Fields under data.* aren't changed and still match exactly.
Type of Change
fix:Bug fix (PATCH version bump)Testing
Added four cases to WorkflowConditions.operators.test.ts for equals, notEquals, contains and notContains on contact.email with a different case. All four fail on next and pass with this change. The workflow test files (WorkflowConditions.operators, WorkflowExecutionService and its integration, ssrf and webhook files, WorkflowService) pass: 204 tests. eslint and tsc for apps/api are clean.
Checklist
Related Issues
None. Related to #489, which lowercases stored emails. The value typed into a workflow condition is still compared as typed, so this change is needed either way.