windmill-labs/windmill · error
`oneOf` needs to be an array
Error message
`oneOf` needs to be an array
What it means
`SchemaValidationRule::from_primitive` encountered `oneOf` on an object-typed schema where the `oneOf` value is not a JSON array. Windmill builds a map of labeled variants from the array, so a non-array `oneOf` is rejected.
Source
Thrown at backend/windmill-common/src/schema.rs:87
schema_rules.push(SchemaValidationRule::IsInteger);
}
JsonPrimitiveType::Object => {
let mut obj_rules = vec![];
if let Some(properties) = val.get("properties") {
let properties = properties
.as_object()
.ok_or(anyhow!("Field properties should be an object"))?;
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 {View on GitHub (pinned to e474e8803c)
Solutions
- Make `oneOf` an array of variant schemas, each with a string `title`.
- If you intended free-form object properties, use `properties` instead of `oneOf`.
- Run the schema through a JSON Schema validator before deploying.
Example fix
// before
{ "type": "object", "oneOf": { "title": "A" } }
// after
{ "type": "object", "oneOf": [ { "title": "A", "type": "object", "properties": {} } ] } Defensive patterns
Strategy: validation
Validate before calling
const s = JSON.parse(schemaRaw);
if ("oneOf" in s && !Array.isArray(s.oneOf)) {
throw new Error("`oneOf` must be an array of variant schemas");
} Type guard
function hasValidOneOf(s) {
return !("oneOf" in s) || Array.isArray(s.oneOf);
} Try / catch
try {
await wm.deploy(script);
} catch (e) {
if (String(e.message).includes("oneOf` needs to be an array")) {
throw new Error("Wrap your oneOf value in an array: oneOf: [variant, ...]");
} else throw e;
} Prevention
- Remember Windmill's oneOf requires each variant to carry a unique string title.
- Validate with a JSON Schema tool that catches non-array oneOf.
- Prefer the Windmill schema editor over raw JSON editing when possible.
When it happens
Trigger: A schema with `"type": "object"` and `"oneOf": {...}` (object/string/number instead of an array of variant schemas).
Common situations: Hand-written schemas confusing `oneOf` with `anyOf` or `allOf` semantics, malformed tool-generated output, or editing the schema in the Windmill UI/raw JSON and dropping the array brackets.
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
- oneOf variant definition should have a `title` field
- oneOf variant definition `title` field should be a string
- Field properties should be an object
- oneOf definition has a duplicate variant `{variant_label}`
- Object type should have a `properties` or `anyOf` field, or
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/ecbf5f640977d408.
Report an issue: GitHub.