{"record":{"id":"f95c694002233bac","repo":"windmill-labs/windmill","slug":"variant-name-already-exists","errorCode":null,"errorMessage":"Variant name already exists","messagePattern":"Variant name already exists","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/schema/FlowPropertyEditor.svelte","lineNumber":113,"sourceCode":"\t\t\toneOfSelected = oneOf[0].title\n\t\t}\n\t})\n\n\tconst dispatch = createEventDispatcher()\n\n\tfunction getResourceTypesFromFormat(format: string | undefined): string[] {\n\t\tif (format?.startsWith('resource-')) {\n\t\t\treturn [format.split('-')[1]]\n\t\t}\n\n\t\treturn []\n\t}\n\n\tlet variantName = $state('')\n\tfunction createVariant(name: string) {\n\t\tif (oneOf) {\n\t\t\tif (oneOf.some((obj) => obj.title === name)) {\n\t\t\t\tthrow new Error('Variant name already exists')\n\t\t\t}\n\t\t\tconst idx = oneOf.findIndex((obj) => obj.title === name)\n\t\t\tif (idx === -1) {\n\t\t\t\toneOf = [\n\t\t\t\t\t...oneOf,\n\t\t\t\t\t{\n\t\t\t\t\t\ttitle: name,\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties: {}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t\toneOfSelected = name\n\t\t\t}\n\t\t\tvariantName = ''\n\t\t}\n\t}\n\n\tfunction renameVariant(name: string, selected: string) {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/schema/FlowPropertyEditor.svelte#L95-L131","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pick a different, unique name for the new variant","Delete or rename the existing variant that already holds the name, then create the new one","Catch the error in the UI and surface it as an inline validation message"],"exampleFix":"// before\ncreateVariant('Option 1') // throws if exists\n// after\nif (!oneOf.some(v => v.title !== 'Option 1')) createVariant('Option 1')","handlingStrategy":"validation","validationCode":"const taken = new Set(oneOf.map(v => v.title));\nif (taken.has(name)) throw new Error('Variant name already exists');","typeGuard":"function isUniqueTitle(oneOf: {title: string}[], name: string): boolean {\n  return !oneOf.some(v => v.title === name);\n}","tryCatchPattern":"try { createVariant(name); } catch (e) {\n  if (e.message === 'Variant name already exists') { setFieldError('name', 'Already used'); }\n  else throw e;\n}","preventionTips":["De-duplicate names in the variant input before submit","Show existing variant titles as suggestions/validation in the form","Generate unique default names (Variant 2, Variant 3...) when adding"],"tags":["schema","validation","duplicate","oneof"],"backgroundTag":"duplicate-name-conflict","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}