Files
windmill/backend/migrations/20260614075900_dedup_folder_labels.down.sql
Ruben Fiszel eba70ce735 dedup folder labels to prevent each_key_duplicate crash (#9565)
Folder labels are exposed verbatim as `inherited_labels` (via the
`folder_labels` SQL function) and rendered in keyed `{#each}` blocks that
throw Svelte's `each_key_duplicate` on a repeated key, crashing the list
views. The UI dedups labels on entry, but API / CLI / git-sync writes do
not, so a folder.yaml with `labels: [foo, foo]` persists duplicates.

- Dedup on write in create_folder and update_folder (order-preserving).
- Make folder_labels() dedup on read so it is resilient regardless of how a
  row was populated, plus a one-time cleanup of already-persisted duplicates
  so direct folder.labels reads (folder list, editor) are safe too.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 10:18:05 +02:00

7 lines
373 B
PL/PgSQL

-- Restore the original passthrough definition (the one-time data cleanup is not reverted).
CREATE OR REPLACE FUNCTION folder_labels(w_id text, item_path text) RETURNS text[]
LANGUAGE sql STABLE SECURITY DEFINER SET search_path = public AS $$
SELECT labels FROM folder
WHERE workspace_id = w_id AND item_path LIKE 'f/%' AND name = split_part(item_path, '/', 2)
$$;