windmill-labs/windmill · error

oneOf variant definition `title` field should be a string

Error message

oneOf variant definition `title` field should be a string

What it means

Raised by SchemaValidationRule::from_value in windmill-common while compiling a JSON Schema into internal validation rules: each oneOf variant must carry a string `title` — Windmill uses it to label and select variants at runtime — and one variant's title was absent or not a string. The malformed schema is rejected at parse time rather than producing ambiguous runtime matching.

Source

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

                    for (key, v) in properties {
                        obj_rules.push((key.clone(), SchemaValidationRule::from_value(v)?))
                    }

                    schema_rules.push(SchemaValidationRule::IsObject(obj_rules));
                } else if let Some(one_of) = val.get("oneOf") {
                    let one_of = one_of
                        .as_array()
                        .ok_or(anyhow!("`oneOf` needs to be an array"))?;
                    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")

View on GitHub (pinned to e474e8803c)

Solutions

  1. Change `title` to a plain string value.
  2. Quote YAML titles that would otherwise parse as numbers/booleans.
  3. Validate the schema before deployment to catch malformed titles.

Example fix

// before
{ "title": 1, "type": "object" }
// after
{ "title": "Option 1", "type": "object" }
Defensive patterns

Strategy: validation

Validate before calling

const s = JSON.parse(schemaRaw);
const bad = (s.oneOf ?? []).filter(v => "title" in v && typeof v.title !== "string");
if (bad.length) throw new Error("oneOf `title` values must be strings");

Type guard

function titlesAreStrings(s) {
  return !Array.isArray(s.oneOf) || s.oneOf.every(v => !("title" in v) || typeof v.title === "string");
}

Try / catch

try {
  await deploy(schema);
} catch (e) {
  if (String(e.message).includes("`title` field should be a string")) {
    throw new Error("Convert oneOf variant titles to plain strings");
  } else throw e;
}

Prevention

When it happens

Trigger: A `oneOf` variant with a non-string `title`, e.g. `"title": 1` or `"title": {"en": "A"}`.

Common situations: Programmatic schema generation producing numeric titles, YAML/JSON type coercion (e.g. unquoted title that parses as a number), localization objects used instead of plain strings.

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/85488b4e5ee4f708. Report an issue: GitHub.