From ca3aa29c3a8f7a0af9dbc2e05e613bb45ab40668 Mon Sep 17 00:00:00 2001 From: Arnas Donauskas Date: Mon, 22 Jun 2026 10:20:38 +0300 Subject: [PATCH] fix(automations): persist default match_type for Keyword Match triggers Creating a keyword_match automation with Match type left on the default "Contains" failed activation with `match type must be "exact" or "contains"` (path trigger.match_type). The dropdown showed "Contains" via a display-only fallback, but the value was never written to the config, so the saved payload omitted match_type entirely. Both engines already treat a missing match_type as "contains" (automations/engine.ts, flows/engine.ts), so the activation validator was stricter than runtime. Two coordinated fixes: - validate.ts: accept a missing match_type (defaults to "contains"); only an explicit, unrecognised value is rejected. Aligns the validator with the engines and any non-UI client. - automation-builder.tsx: seed match_type: "contains" on mount of KeywordMatchConfig so the displayed default is actually persisted, keeping the saved record explicit and self-describing. Adds a regression test that a keyword_match config with no match_type passes activation validation. Fixes #271 Co-Authored-By: Claude Opus 4.8 --- src/components/automations/automation-builder.tsx | 12 ++++++++++++ src/lib/automations/validate.test.ts | 6 ++++++ src/lib/automations/validate.ts | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/automations/automation-builder.tsx b/src/components/automations/automation-builder.tsx index 677f62b..e2cba49 100644 --- a/src/components/automations/automation-builder.tsx +++ b/src/components/automations/automation-builder.tsx @@ -723,6 +723,18 @@ function KeywordMatchConfig({ // when the trigger type changes, so the seed stays in sync. const [draft, setDraft] = useState(keywords.join(", ")) + // Persist the default the