{"record":{"id":"99f01e0da159656d","repo":"windmill-labs/windmill","slug":"no-script-draft-found-for-path","errorCode":null,"errorMessage":"No script draft found for \"${path}\".","messagePattern":"No script draft found for \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/global/core.ts","lineNumber":6229,"sourceCode":"): 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}).`\n\t\ttoolCallbacks.setToolStatus(toolId, { content: message })\n\t\treturn JSON.stringify({ success: true, alreadyLatest: true, latest_hash: latest.hash, message })\n\t}\n\n\ttoolCallbacks.setToolStatus(toolId, { content: `Rebasing draft \"${path}\" onto latest...` })\n\n\t// Capture the draft's own changes (vs its fork base) BEFORE discarding — this\n\t// diff is the only clean record of what to replay. Best-effort: if the base\n\t// version is gone, diff against empty so the full draft is surfaced.","sourceCodeStart":6211,"sourceCodeEnd":6247,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/global/core.ts#L6211-L6247","documentation":"Thrown by rebaseScriptDraft when no script draft is stored for the path, or the draft has no string value or language. Rebase diffs a draft against a newer deployed version; with no draft there is nothing to carry forward, so the tool fails instead of returning an empty diff.","triggerScenarios":"Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:6229 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create a draft first via write_script or edit_script, then rebase","Verify the path points at the item whose draft you forked","If the draft was already discarded, re-apply the saved diff with write_script instead of rebasing"],"exampleFix":null,"handlingStrategy":"try-catch","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"}