From e716db52919e1f9a4e192a688f59a006b12a28a7 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Wed, 9 Sep 2026 12:25:05 +0200 Subject: [PATCH] fix: run the post-write moved re-assert under RLS, not the raw pool Co-Authored-By: Claude Opus 5 (1M context) --- backend/windmill-api/src/drafts.rs | 44 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/backend/windmill-api/src/drafts.rs b/backend/windmill-api/src/drafts.rs index f5108b2c57..2ee92aa030 100644 --- a/backend/windmill-api/src/drafts.rs +++ b/backend/windmill-api/src/drafts.rs @@ -379,20 +379,6 @@ impl DraftBaseVersion { } } -/// Where the item that used to live at `path` went, for a draft still bound to -/// the old path. Resolved from the version the draft already carries — every -/// kind keeps a pointer that outlives a rename: -/// - flows: `flow_version.path` is rewritten before the old row is deleted; -/// - apps: `app_version` points at the app's surrogate id, which never moves; -/// - scripts: the new version prepends the old hash onto `parent_hashes`. -/// -/// `None` (⇒ save normally) when the draft carries no base version (a genuine -/// draft-only item), when the lineage is gone (item deleted, or recreated at -/// the new path by a CLI/git-sync push that leaves no lineage), or when the -/// caller can't see where it went. -/// -/// Read under RLS so the answer can never reveal an item the caller has no -/// access to. /// The version this draft forked from, or `None` when it has no lineage to /// follow — a kind that keeps none, a malformed payload, or a draft that was /// never forked from a deploy. Pure: no queries. This is the escape hatch the @@ -416,6 +402,22 @@ fn draft_lineage(kind: UserDraftItemKind, value: &str) -> Option