From 12b9f4feccfa89d08c6d878f423a86d0415c71ef Mon Sep 17 00:00:00 2001 From: hugocasa Date: Thu, 24 Sep 2026 10:08:42 +0200 Subject: [PATCH] fix: notify when a resource is retyped to an internal type Co-Authored-By: Claude Opus 5.5 (1M context) --- .../migrations/20260924065755_mcp_tools_change_notify.up.sql | 2 +- backend/windmill-store/src/resources.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/migrations/20260924065755_mcp_tools_change_notify.up.sql b/backend/migrations/20260924065755_mcp_tools_change_notify.up.sql index a661ff0109..09d7ade59f 100644 --- a/backend/migrations/20260924065755_mcp_tools_change_notify.up.sql +++ b/backend/migrations/20260924065755_mcp_tools_change_notify.up.sql @@ -59,7 +59,7 @@ EXECUTE FUNCTION notify_mcp_tools_change(); CREATE TRIGGER resource_mcp_tools_update_trigger AFTER UPDATE OF path, resource_type, description ON resource FOR EACH ROW -WHEN (NEW.resource_type NOT IN ('cache', 'state') +WHEN ((OLD.resource_type NOT IN ('cache', 'state') OR NEW.resource_type NOT IN ('cache', 'state')) AND (OLD.path IS DISTINCT FROM NEW.path OR OLD.resource_type IS DISTINCT FROM NEW.resource_type OR OLD.description IS DISTINCT FROM NEW.description)) diff --git a/backend/windmill-store/src/resources.rs b/backend/windmill-store/src/resources.rs index 5bb15b456e..5dc1ada20a 100644 --- a/backend/windmill-store/src/resources.rs +++ b/backend/windmill-store/src/resources.rs @@ -1075,7 +1075,8 @@ async fn check_path_conflict<'c>( /// Resource types the platform writes on its own behalf rather than users editing them: /// `state` backs `setState` and `cache` backs cached job results, so both are rewritten on /// every job run. Workspace export skips them for the same reason the `record_resource_version` -/// trigger does; that trigger repeats this list in SQL, so the two have to move together. +/// trigger does; that trigger and the `notify_mcp_tools_change` resource triggers repeat this +/// list in SQL, so they have to move together. pub const INTERNAL_RESOURCE_TYPES: [&str; 2] = ["state", "cache"]; /// Versions retained per resource path. The monitor sweep enforces it eventually; the history