windmill-labs/windmill · error · Error

YAML sync failed

Error message

YAML sync failed

What it means

handleSave in SuperadminSettings first asks the inner settings component to sync its form state into YAML (syncBeforeDiff) before persisting. If the inner component reports sync failure (falsy return), the save aborts with this Error so a stale-YAML write never happens silently.

Source

Thrown at frontend/src/lib/components/SuperadminSettings.svelte:72

	function handleClose() {
		if (hasUnsavedChanges) {
			showCloseConfirmModal = true
		} else {
			closeDrawer()
		}
	}

	/** Catches click-away and escape closes from the Drawer/Disposable layer */
	function handleDrawerClose() {
		if (!bypassCloseCheck && hasUnsavedChanges) {
			drawer?.openDrawer()
			showCloseConfirmModal = true
		}
		bypassCloseCheck = false
	}

	async function handleSave(): Promise<void> {
		if (!innerComponent?.syncBeforeDiff()) throw new Error('YAML sync failed')
		await innerComponent?.saveSettings()
	}

	async function handleSaveAndCloseDiff(): Promise<void> {
		await handleSave()
		diffDrawer?.closeDrawer()
	}

	function handleDiscard() {
		innerComponent?.discardAll()
	}

	function handleReviewChanges() {
		if (!innerComponent?.syncBeforeDiff()) return
		diffData = innerComponent?.buildFullDiff() ?? { original: '', modified: '' }
		diffDrawer?.openDrawer()
	}
</script>

View on GitHub (pinned to e474e8803c)

Solutions

  1. Fix YAML syntax errors in the settings YAML editor so it parses and syncs
  2. Reopen the settings/diff drawer to remount the inner component and retry
  3. Check the browser console for the underlying sync error reported by the inner component
  4. Save via the form (not the diff drawer) if the YAML state is unrecoverable

Example fix

// before
if (!innerComponent?.syncBeforeDiff()) throw new Error('YAML sync failed')
// after
if (!innerComponent) throw new Error('Settings not loaded yet')
if (!innerComponent.syncBeforeDiff()) {
  sendUserToast('Could not sync YAML settings — check YAML syntax', true)
  return
}
Defensive patterns

Strategy: validation

Validate before calling

// validate YAML parses before attempting save/sync
try { window.jsyaml.load(yamlText) } catch (e) { sendUserToast('Invalid YAML: ' + e.message, true) }

Type guard

function innerReady(c: unknown): c is { syncBeforeDiff(): boolean; saveSettings(): Promise<void> } {
  return !!c && typeof (c as any).syncBeforeDiff === 'function'
}

Try / catch

try {
  await handleSave()
} catch (e) {
  if (e.message === 'YAML sync failed') {
    sendUserToast('Fix YAML syntax before saving', true)
  } else throw e
}

Prevention

When it happens

Trigger: Clicking save (or Save-and-close-diff via handleSaveAndCloseDiff) when innerComponent?.syncBeforeDiff() returns false — the YAML editor content could not be reconciled with form state, typically due to invalid YAML or a desynchronized inner component ref.

Common situations: Hand-edited YAML in the diff drawer with syntax errors; switching between form and YAML views leaving stale state; innerComponent ref not yet mounted when save is triggered.

Related errors


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