{"record":{"id":"dd1d78ea1d39d0cf","repo":"windmill-labs/windmill","slug":"rebase-draft-currently-supports-scripts-flows-an","errorCode":null,"errorMessage":"rebase_draft currently supports scripts, flows, and apps.","messagePattern":"rebase_draft currently supports scripts, flows, and apps\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":6220,"sourceCode":"\n// Discard a stale draft and return its own changes (vs the fork base) as a diff so\n// the model can re-apply them on the latest deploy. Discarding rather than resetting\n// keeps the base pointer honest (the next write re-bases on the current head) and\n// fails safe: a premature deploy hits \"no draft\" instead of silently shipping the\n// latest unchanged.\nasync function rebaseDraft(\n\targs: { type: WorkspaceItemType; path: string },\n\tctx: WriteDraftCtx\n): Promise<string> {\n\tswitch (args.type) {\n\t\tcase 'script':\n\t\t\treturn rebaseScriptDraft(args.path, ctx)\n\t\tcase 'flow':\n\t\t\treturn rebaseFlowDraft(args.path, ctx)\n\t\tcase 'app':\n\t\t\treturn rebaseAppDraft(args.path, ctx)\n\t\tdefault:\n\t\t\tthrow new Error('rebase_draft currently supports scripts, flows, and apps.')\n\t}\n}\n\nasync function rebaseScriptDraft(path: string, ctx: WriteDraftCtx): Promise<string> {\n\tconst { workspace, toolId, toolCallbacks } = ctx\n\n\tconst draft = await getGlobalDraft(workspace, 'script', path)\n\tif (!draft || typeof draft.value !== 'string' || !draft.language) {\n\t\tthrow new Error(`No script draft found for \"${path}\".`)\n\t}\n\tif (!(await ScriptService.existsScriptByPath({ workspace, path }))) {\n\t\tthrow new Error(`Script \"${path}\" is not deployed; there is no newer version to rebase onto.`)\n\t}\n\n\tconst latest = await ScriptService.getScriptByPath({ workspace, path })\n\tconst baseHash = draft.parentHash\n\tif (baseHash && baseHash === latest.hash) {\n\t\tconst message = `Draft \"${path}\" is already based on the latest deployed version (${latest.hash}).`","sourceCodeStart":6202,"sourceCodeEnd":6238,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L6202-L6238","documentation":"Thrown by rebaseDraft's default switch branch when the requested WorkspaceItemType is outside the supported set (script, flow, app). The rebase_draft tool computes a draft-vs-fork-base diff, which is only implemented for those three types; other item types (variables, resources, schedules, ...) are rejected outright rather than silently mishandled.","triggerScenarios":"Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:6220 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call rebase_draft only with type 'script', 'flow', or 'app'","For other workspace item types, use the item-specific diff or discard tools instead","If a new item type becomes draftable, extend rebaseDraft rather than passing it through"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}