{"record":{"id":"61dfdb572e193625","repo":"windmill-labs/windmill","slug":"cannot-load-drafts-of-kind-itemkind","errorCode":null,"errorMessage":"Cannot load drafts of kind ${itemKind}","messagePattern":"Cannot load drafts of kind (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/otherUserDraftLoad.svelte.ts","lineNumber":66,"sourceCode":"// One-shot handoff: set by the Load action, consumed by the editor's loader.\nconst pending = new SvelteMap<string, PendingOtherUserDraftLoad>()\n// Live overlay sessions, keyed by (workspace, itemKind, path).\nconst active = new SvelteMap<string, ActiveSession>()\n// Keys whose overwrite-confirmation modal is currently open.\nconst overwriteOpen = new SvelteSet<string>()\n\nexport function editRouteFor(itemKind: UserDraftItemKind, path: string): string {\n\tswitch (itemKind) {\n\t\tcase 'script':\n\t\t\treturn `${base}/scripts/edit/${path}`\n\t\tcase 'flow':\n\t\t\treturn `${base}/flows/edit/${path}`\n\t\tcase 'app':\n\t\t\treturn `${base}/apps/edit/${path}`\n\t\tcase 'raw_app':\n\t\t\treturn `${base}/apps_raw/edit/${path}`\n\t\tdefault:\n\t\t\tthrow new Error(`Cannot load drafts of kind ${itemKind}`)\n\t}\n}\n\nexport const OtherUserDraftLoad = {\n\t/**\n\t * Stage a load. The editor's loader picks it up via `takePending`. When\n\t * `navigate`, route to the item's edit page (home-page entry point); the\n\t * in-editor entry point reloads in place instead.\n\t */\n\tstage(\n\t\tworkspace: string,\n\t\titemKind: UserDraftItemKind,\n\t\tvalue: unknown,\n\t\tpath: string,\n\t\townerLabel: string,\n\t\topts: { navigate: boolean }\n\t): void {\n\t\tpending.set(keyOf(workspace, itemKind, path), { workspace, itemKind, path, value, ownerLabel })","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/otherUserDraftLoad.svelte.ts#L48-L84","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncase 'raw_app':\n  return `${base}/apps_raw/edit/${path}`\ndefault:\n  throw new Error(`Cannot load drafts of kind ${itemKind}`)\n// after\ncase 'raw_app':\n  return `${base}/apps_raw/edit/${path}`\ncase 'resource':\n  return `${base}/resources/edit/${path}`\ndefault:\n  throw new Error(`Cannot load drafts of kind ${itemKind}`)","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['script','flow','app','raw_app']\nif (!SUPPORTED.includes(itemKind)) return null // skip staging instead of throwing","typeGuard":"function isDraftableKind(k: string): k is 'script'|'flow'|'app'|'raw_app' {\n  return ['script','flow','app','raw_app'].includes(k)\n}","tryCatchPattern":"try { route = editRouteFor(kind) } catch { route = null; showUnsupportedNotice(kind) }","preventionTips":["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"],"tags":["drafts","navigation","unsupported-kind"],"backgroundTag":"unsupported-draft-kind","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}