windmill-labs/windmill · error
Cannot load drafts of kind ${itemKind}
Error message
Cannot load drafts of kind ${itemKind} What it means
editRouteFor maps a draft item kind (script, flow, app, raw_app) to its editor route. When OtherUserDraftLoad is asked to stage a draft of a kind that has no known editor route, it throws. It is a guard against viewing drafts of unsupported item types.
Source
Thrown at frontend/src/lib/components/otherUserDraftLoad.svelte.ts:66
// One-shot handoff: set by the Load action, consumed by the editor's loader.
const pending = new SvelteMap<string, PendingOtherUserDraftLoad>()
// Live overlay sessions, keyed by (workspace, itemKind, path).
const active = new SvelteMap<string, ActiveSession>()
// Keys whose overwrite-confirmation modal is currently open.
const overwriteOpen = new SvelteSet<string>()
export function editRouteFor(itemKind: UserDraftItemKind, path: string): string {
switch (itemKind) {
case 'script':
return `${base}/scripts/edit/${path}`
case 'flow':
return `${base}/flows/edit/${path}`
case 'app':
return `${base}/apps/edit/${path}`
case 'raw_app':
return `${base}/apps_raw/edit/${path}`
default:
throw new Error(`Cannot load drafts of kind ${itemKind}`)
}
}
export const OtherUserDraftLoad = {
/**
* Stage a load. The editor's loader picks it up via `takePending`. When
* `navigate`, route to the item's edit page (home-page entry point); the
* in-editor entry point reloads in place instead.
*/
stage(
workspace: string,
itemKind: UserDraftItemKind,
value: unknown,
path: string,
ownerLabel: string,
opts: { navigate: boolean }
): void {
pending.set(keyOf(workspace, itemKind, path), { workspace, itemKind, path, value, ownerLabel })View on GitHub (pinned to e474e8803c)
Solutions
- Extend the switch in editRouteFor with a case returning the editor route for the new kind
- Check the draft record's kind field — fix stale data or the producer writing the wrong kind
- If the kind should not be draftable, filter it out before calling stage
Example fix
// before
case 'raw_app':
return `${base}/apps_raw/edit/${path}`
default:
throw new Error(`Cannot load drafts of kind ${itemKind}`)
// after
case 'raw_app':
return `${base}/apps_raw/edit/${path}`
case 'resource':
return `${base}/resources/edit/${path}`
default:
throw new Error(`Cannot load drafts of kind ${itemKind}`) Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = ['script','flow','app','raw_app'] if (!SUPPORTED.includes(itemKind)) return null // skip staging instead of throwing
Type guard
function isDraftableKind(k: string): k is 'script'|'flow'|'app'|'raw_app' {
return ['script','flow','app','raw_app'].includes(k)
} Try / catch
try { route = editRouteFor(kind) } catch { route = null; showUnsupportedNotice(kind) } Prevention
- Keep the supported-kinds list next to the type union and update both together
- Filter draft lists by known kinds before offering 'open draft'
- Add a test that iterates all item kinds through editRouteFor
When it happens
Trigger: Calling OtherUserDraftLoad.stage (which calls editRouteFor) with itemKind set to anything other than 'script', 'flow', 'app', or 'raw_app' — e.g. a new resource/kind added elsewhere but not wired into this switch.
Common situations: Loading another user's draft of a newly added item kind before this switch was extended; a stale or malformed draft record whose kind field was corrupted or renamed.
Related errors
- Cannot diff drafts of kind ${itemKind}
- state.failureMessage ?? `Failed to delete draft "${path}".`
- Draft "${path}" changed externally since you last read it; i
- res.error ?? 'discard failed'
- This page has changes that are not valid JSON. Fix them firs
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/61dfdb572e193625.
Report an issue: GitHub.