windmill-labs/windmill · error

Cannot diff drafts of kind ${itemKind}

Error message

Cannot diff drafts of kind ${itemKind}

What it means

fetchDeployedValueForDiff maps a draft item's kind to the deployed object it should be diffed against. The default branch throws for kinds that have no deployed-value mapping, so the diff view cannot compare that draft kind.

Source

Thrown at frontend/src/lib/components/otherUserDraftDiff.ts:45

		case 'flow':
			return (await FlowService.getFlowByPath({ workspace, path })) as unknown as Value
		case 'app':
			return (await AppService.getAppByPath({ workspace, path, getDraft: false }))
				.value as unknown as Value
		case 'raw_app': {
			const app = await AppService.getAppByPath({ workspace, path, getDraft: false })
			const v = (app.value ?? {}) as any
			return {
				files: v.files,
				runnables: v.runnables,
				data: extractDataConfig(v) ?? { ...DEFAULT_DATA },
				summary: app.summary,
				policy: app.policy,
				custom_path: app.custom_path
			} as unknown as Value
		}
		default:
			throw new Error(`Cannot diff drafts of kind ${itemKind}`)
	}
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Add a case for the missing kind in fetchDeployedValueForDiff that fetches its deployed value.
  2. Filter such items out of the diff UI, showing 'diff unavailable' instead of invoking the fetch.
  3. Verify itemKind is correct at the call site (undefined/kind mismatch is common).
  4. If the kind was recently renamed, update the switch's case labels to the new name.

Example fix

// before
default: throw new Error(`Cannot diff drafts of kind ${itemKind}`)
// after
case 'schedule':
  return await ScheduleService.getSchedule({ workspace, path: item.path }) as unknown as Value
default: throw new Error(`Cannot diff drafts of kind ${itemKind}`)
Defensive patterns

Strategy: validation

Validate before calling

const DIFFABLE_KINDS = ['script', 'flow', 'app', 'raw_app']
if (!DIFFABLE_KINDS.includes(itemKind)) return null // show 'diff unavailable'

Type guard

function canDiff(kind) { return DIFFABLE_KINDS.includes(kind) }

Try / catch

try { const deployed = await fetchDeployedValueForDiff(itemKind, item) } catch (e) { if (String(e.message).startsWith('Cannot diff drafts of kind')) showNoDiffPlaceholder(item); else throw e }

Prevention

When it happens

Trigger: Calling the draft-diff flow with an itemKind not handled by the switch (anything beyond the supported script/flow/app-style kinds) — e.g. a new draft kind added elsewhere without extending this function.

Common situations: A newly introduced resource kind whose diff support was not added to otherUserDraftDiff.ts; passing a malformed/undefined kind from a listing; a kind rename on the backend not mirrored here.

Related errors


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