windmill-labs/windmill · error

oneOf definition has a duplicate variant

Error message

oneOf definition has a duplicate variant `{variant_label}`

What it means

Windmill keys `oneOf` variants by their `title`; when two variants in the same `oneOf` array share the same title, the second would silently overwrite the first in the rules map. Instead, parsing aborts with this error naming the duplicated variant.

Solutions

  1. Rename each variant's `title` to a unique string.
  2. Deduplicate variants that are truly identical (keep one).
  3. Add a deployment-time JSON Schema check to catch duplicate titles early.

Example fix

// before
{ "oneOf": [ { "title": "A", "type": "string" }, { "title": "A", "type": "number" } ] }
// after
{ "oneOf": [ { "title": "A (string)", "type": "string" }, { "title": "A (number)", "type": "number" } ] }
Defensive patterns

Strategy: validation

Validate before calling

const s = JSON.parse(schemaRaw);
if (Array.isArray(s.oneOf)) {
  const titles = s.oneOf.map(v => v?.title);
  const dupes = titles.filter((t, i) => titles.indexOf(t) !== i);
  if (dupes.length) throw new Error(`Duplicate oneOf titles: ${[...new Set(dupes)]}`);
}

Type guard

function hasUniqueVariantTitles(s) {
  if (!Array.isArray(s.oneOf)) return true;
  const titles = s.oneOf.map(v => v?.title);
  return new Set(titles).size === titles.length;
}

Try / catch

try {
  await deploy(schema);
} catch (e) {
  const m = String(e.message).match(/duplicate variant `(.*?)`/);
  if (m) throw new Error(`Rename the duplicated variant title "${m[1]}"`);
  throw e;
}

Prevention

When it happens

Trigger: A `oneOf` array containing two or more variant schemas whose `title` strings are identical, encountered while parsing the object schema.

Common situations: Duplicating a variant block and forgetting to rename its title; generator templates emitting the same default title; merging schemas from multiple sources.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at backend/windmill-common/src/schema.rs:106

                    let mut rules_map: HashMap<String, Vec<SchemaValidationRule>> = HashMap::new();

                    for variant in one_of {
                        let variant_label = variant
                            .get("title")
                            .ok_or(anyhow!(
                                "oneOf variant definition should have a `title` field"
                            ))?
                            .as_str()
                            .ok_or(anyhow!(
                                "oneOf variant definition `title` field should be a string"
                            ))?;
                        if !rules_map.contains_key(variant_label) {
                            rules_map.insert(
                                variant_label.to_string(),
                                SchemaValidationRule::from_value(variant)?,
                            );
                        } else {
                            return Err(anyhow!(
                                "oneOf definition has a duplicate variant `{variant_label}`"
                            ));
                        }
                    }

                    schema_rules.push(SchemaValidationRule::IsOneOf(rules_map))
                } else {
                    let is_resource = val
                        .get("format")
                        .and_then(|f| f.as_str())
                        .map(|f| f.starts_with("resource"))
                        .unwrap_or(false);
                    if !is_resource {
                        return Err(anyhow!(
                        "Object type should have a `properties` or `anyOf` field, or be a resource"
                        ));
                    }
                }

View on GitHub (pinned to e474e8803c)