From e4856faea0fbbe78c87132339c355aadbd010907 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Mon, 6 Jul 2026 23:11:40 +0200 Subject: [PATCH] fix(git-sync): skip deleted/archived workspaces in the auto-pull poller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The poller scanned workspace_settings directly, so an archived (soft-deleted) or renamed-away workspace — whose settings row persists — kept polling and could enqueue a pull into a dead workspace. Join workspace and require NOT deleted. The EE webhook receiver gets the same filter (ee ref bumped). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01PP5gBSPfo1YtkL1sWVAjJm --- ...570a14d22ed2a776efa111ad53aa9e77eadf1.json | 26 +++++++++++++++++++ ...78f7253e4470287810d7ee13b8519f54b997f.json | 22 ++++++++++++++++ backend/ee-repo-ref.txt | 2 +- backend/src/monitor.rs | 14 +++++++--- 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 backend/.sqlx/query-bfbc368c751c8532792ae0a77ed570a14d22ed2a776efa111ad53aa9e77eadf1.json create mode 100644 backend/.sqlx/query-c92c08a4b4c06d087c2590081db78f7253e4470287810d7ee13b8519f54b997f.json diff --git a/backend/.sqlx/query-bfbc368c751c8532792ae0a77ed570a14d22ed2a776efa111ad53aa9e77eadf1.json b/backend/.sqlx/query-bfbc368c751c8532792ae0a77ed570a14d22ed2a776efa111ad53aa9e77eadf1.json new file mode 100644 index 0000000000..1d92609205 --- /dev/null +++ b/backend/.sqlx/query-bfbc368c751c8532792ae0a77ed570a14d22ed2a776efa111ad53aa9e77eadf1.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT ws.workspace_id, ws.git_sync\n FROM workspace_settings ws\n JOIN workspace w ON w.id = ws.workspace_id\n WHERE NOT w.deleted\n AND ws.git_sync IS NOT NULL\n AND ws.git_sync->'repositories' @> '[{\"auto_pull\": {\"enabled\": true}}]'::jsonb", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "workspace_id", + "type_info": "Varchar" + }, + { + "ordinal": 1, + "name": "git_sync", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + false, + true + ] + }, + "hash": "bfbc368c751c8532792ae0a77ed570a14d22ed2a776efa111ad53aa9e77eadf1" +} diff --git a/backend/.sqlx/query-c92c08a4b4c06d087c2590081db78f7253e4470287810d7ee13b8519f54b997f.json b/backend/.sqlx/query-c92c08a4b4c06d087c2590081db78f7253e4470287810d7ee13b8519f54b997f.json new file mode 100644 index 0000000000..46ce3af568 --- /dev/null +++ b/backend/.sqlx/query-c92c08a4b4c06d087c2590081db78f7253e4470287810d7ee13b8519f54b997f.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT ws.git_sync FROM workspace_settings ws\n JOIN workspace w ON w.id = ws.workspace_id\n WHERE ws.workspace_id = $1 AND NOT w.deleted", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "git_sync", + "type_info": "Jsonb" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + true + ] + }, + "hash": "c92c08a4b4c06d087c2590081db78f7253e4470287810d7ee13b8519f54b997f" +} diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index b12c25cf59..f8e2dccb84 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -6e2f282fe951cfbbab9d4b831d0e550bb1952854 +bdc29c9c3a63891677ac01b1baab41753ea0ec45 diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index aebfc82872..e7adbd2715 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -3141,11 +3141,17 @@ const AUTO_PULL_POLL_SLACK_S: i64 = 30; async fn poll_git_auto_pull_inner(db: &Pool) -> error::Result<()> { use windmill_common::workspaces::{AutoPullMode, WorkspaceGitSyncSettings}; + // Join `workspace` and skip deleted/archived ones: their `workspace_settings` + // rows persist (archive is a soft delete, and change_workspace_id leaves the old + // id as an archived shell), so an auto-pull repo would otherwise keep polling and + // deploying into a dead workspace. let rows = sqlx::query!( - r#"SELECT workspace_id, git_sync - FROM workspace_settings - WHERE git_sync IS NOT NULL - AND git_sync->'repositories' @> '[{"auto_pull": {"enabled": true}}]'::jsonb"# + r#"SELECT ws.workspace_id, ws.git_sync + FROM workspace_settings ws + JOIN workspace w ON w.id = ws.workspace_id + WHERE NOT w.deleted + AND ws.git_sync IS NOT NULL + AND ws.git_sync->'repositories' @> '[{"auto_pull": {"enabled": true}}]'::jsonb"# ) .fetch_all(db) .await?;