windmill-labs/windmill · error

Variant name already exists

Error message

Variant name already exists

What it means

createVariant() in FlowPropertyEditor refuses to add a new oneOf variant whose title matches an existing variant. It checks oneOf.some(obj => obj.title === name) and throws before mutating the schema, preventing duplicate variant titles that would break discriminated-union editing.

Source

Thrown at frontend/src/lib/components/schema/FlowPropertyEditor.svelte:113

			oneOfSelected = oneOf[0].title
		}
	})

	const dispatch = createEventDispatcher()

	function getResourceTypesFromFormat(format: string | undefined): string[] {
		if (format?.startsWith('resource-')) {
			return [format.split('-')[1]]
		}

		return []
	}

	let variantName = $state('')
	function createVariant(name: string) {
		if (oneOf) {
			if (oneOf.some((obj) => obj.title === name)) {
				throw new Error('Variant name already exists')
			}
			const idx = oneOf.findIndex((obj) => obj.title === name)
			if (idx === -1) {
				oneOf = [
					...oneOf,
					{
						title: name,
						type: 'object',
						properties: {}
					}
				]
				oneOfSelected = name
			}
			variantName = ''
		}
	}

	function renameVariant(name: string, selected: string) {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Pick a different, unique name for the new variant
  2. Delete or rename the existing variant that already holds the name, then create the new one
  3. Catch the error in the UI and surface it as an inline validation message

Example fix

// before
createVariant('Option 1') // throws if exists
// after
if (!oneOf.some(v => v.title !== 'Option 1')) createVariant('Option 1')
Defensive patterns

Strategy: validation

Validate before calling

const taken = new Set(oneOf.map(v => v.title));
if (taken.has(name)) throw new Error('Variant name already exists');

Type guard

function isUniqueTitle(oneOf: {title: string}[], name: string): boolean {
  return !oneOf.some(v => v.title === name);
}

Try / catch

try { createVariant(name); } catch (e) {
  if (e.message === 'Variant name already exists') { setFieldError('name', 'Already used'); }
  else throw e;
}

Prevention

When it happens

Trigger: Calling createVariant with a name string that equals the title of any existing variant in the oneOf array, e.g. submitting the variant-name input in the schema editor with a name already used.

Common situations: Reusing a default variant name ('Variant', 'Option 1') after adding one; pasting a schema then trying to re-create the same variant; renaming confusion where the target name already belongs to another variant.

Related errors


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