windmill-labs/windmill · error

Cannot deploy ${label}: the draft has a conflicting newer ve

Error message

Cannot deploy ${label}: the draft has a conflicting newer version on the server. Open it in the editor and resolve the conflict first.

What it means

Thrown by flushDraftOrThrow in the Windmill AI chat's global-mode deploy tool. Before deploying an item, the chat flushes its in-browser draft store (UserDraftDbSyncer) to the server; if the syncer reports a conflict — i.e. the server holds a newer version than the local draft was based on — the deploy is aborted rather than silently overwriting someone else's changes. The error tells the user (and the AI agent) to open the item in the Windmill editor and resolve the version conflict manually before deploying again.

Source

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

	toolCallbacks.setToolStatus(toolId, {
		content: `Found ${totalMatchCount} matching changed line${totalMatchCount === 1 ? '' : 's'}`
	})
	return out.join('\n') + unflushedNote
}

// Flush a draft's pending editor autosave, then verify it actually landed before
// the caller re-reads the persisted draft. `flush()` resolves even when the save
// recorded a conflict (server has a newer version) or failed (network/5xx) — it
// does not throw — so without this check a deploy could publish a stale/conflicting
// draft. Abort with a clear message instead.
async function flushDraftOrThrow(
	query: Parameters<typeof UserDraftDbSyncer.flush>[0],
	label: string
): Promise<void> {
	await UserDraftDbSyncer.flush(query)
	if (UserDraftDbSyncer.getConflict(query).conflict) {
		throw new Error(
			`Cannot deploy ${label}: the draft has a conflicting newer version on the server. Open it in the editor and resolve the conflict first.`
		)
	}
	const { state, failureMessage } = UserDraftDbSyncer.getState(query)
	if (state === 'failed') {
		throw new Error(
			`Cannot deploy ${label}: saving the latest draft failed (${failureMessage ?? 'unknown error'}). Retry once the draft saves.`
		)
	}
}

async function deployDraft(
	args: {
		type: WorkspaceItemType
		path: string
		trigger_kind?: TriggerKind
		deployment_message?: string
		force?: boolean

View on GitHub (pinned to e474e8803c)

Solutions

  1. Open the item in the Windmill editor and resolve the conflict (the editor shows the conflicting server vs draft versions), then retry the deploy.
  2. Discard the local draft to accept the server version, re-apply your intended changes, and deploy again.
  3. If the AI agent hit this, re-run the deploy step after the human resolves the conflict in the editor.

Example fix

// before (deploy fails)
await deployDraft({ type: 'script', path: 'f/process', ... })
// Error: Cannot deploy script "f/process": the draft has a conflicting newer version on the server.

// after: open f/process in the editor, resolve the conflict, then retry
await deployDraft({ type: 'script', path: 'f/process', ... }) // succeeds
Defensive patterns

Strategy: try-catch

Validate before calling

import { UserDraftDbSyncer } from '$lib/components/copilot/chat/global/userDraftSyncer'
// before deploying:
if (UserDraftDbSyncer.getConflict(query).conflict) {
  // resolve in editor first; skip the deploy call
}

Type guard

function hasDraftConflict(query) {
  return UserDraftDbSyncer.getConflict(query).conflict === true
}

Try / catch

try {
  await deployDraft(args)
} catch (e) {
  if (/conflicting newer version on the server/.test(e.message)) {
    // surface 'resolve conflict in editor' guidance to the user
  } else throw e
}

Prevention

When it happens

Trigger: Calling the chat's deploy tool (deployDraft → flushDraftOrThrow) when UserDraftDbSyncer.getConflict(query).conflict is true after a flush — i.e. the draft was edited concurrently (by the agent and a human, or in two tabs) so the server version advanced past the draft's base version.

Common situations: Two browser tabs editing the same script/flow/app draft; a human editing the item in the editor while the AI copilot is deploying it; a stale draft left open from before a teammate's deploy; agent-driven bulk edits racing with manual edits in one workspace.

Related errors


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