windmill-labs/windmill · error

No script draft found for "${path}".

Error message

No script draft found for "${path}".

What it means

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.

Source

Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:6229

): Promise<string> {
	switch (args.type) {
		case 'script':
			return rebaseScriptDraft(args.path, ctx)
		case 'flow':
			return rebaseFlowDraft(args.path, ctx)
		case 'app':
			return rebaseAppDraft(args.path, ctx)
		default:
			throw new Error('rebase_draft currently supports scripts, flows, and apps.')
	}
}

async function rebaseScriptDraft(path: string, ctx: WriteDraftCtx): Promise<string> {
	const { workspace, toolId, toolCallbacks } = ctx

	const draft = await getGlobalDraft(workspace, 'script', path)
	if (!draft || typeof draft.value !== 'string' || !draft.language) {
		throw new Error(`No script draft found for "${path}".`)
	}
	if (!(await ScriptService.existsScriptByPath({ workspace, path }))) {
		throw new Error(`Script "${path}" is not deployed; there is no newer version to rebase onto.`)
	}

	const latest = await ScriptService.getScriptByPath({ workspace, path })
	const baseHash = draft.parentHash
	if (baseHash && baseHash === latest.hash) {
		const message = `Draft "${path}" is already based on the latest deployed version (${latest.hash}).`
		toolCallbacks.setToolStatus(toolId, { content: message })
		return JSON.stringify({ success: true, alreadyLatest: true, latest_hash: latest.hash, message })
	}

	toolCallbacks.setToolStatus(toolId, { content: `Rebasing draft "${path}" onto latest...` })

	// Capture the draft's own changes (vs its fork base) BEFORE discarding — this
	// diff is the only clean record of what to replay. Best-effort: if the base
	// version is gone, diff against empty so the full draft is surfaced.

View on GitHub (pinned to e474e8803c)

Solutions

  1. Create a draft first via write_script or edit_script, then rebase
  2. Verify the path points at the item whose draft you forked
  3. If the draft was already discarded, re-apply the saved diff with write_script instead of rebasing
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at frontend/src/lib/components/copilot/chat/global/core.ts:6229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/99f01e0da159656d. Report an issue: GitHub.