{"record":{"id":"ecbf5f640977d408","repo":"windmill-labs/windmill","slug":"oneof-needs-to-be-an-array","errorCode":null,"errorMessage":"`oneOf` needs to be an array","messagePattern":"`oneOf` needs to be an array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":87,"sourceCode":"                schema_rules.push(SchemaValidationRule::IsInteger);\n            }\n            JsonPrimitiveType::Object => {\n                let mut obj_rules = vec![];\n\n                if let Some(properties) = val.get(\"properties\") {\n                    let properties = properties\n                        .as_object()\n                        .ok_or(anyhow!(\"Field properties should be an object\"))?;\n\n                    for (key, v) in properties {\n                        obj_rules.push((key.clone(), SchemaValidationRule::from_value(v)?))\n                    }\n\n                    schema_rules.push(SchemaValidationRule::IsObject(obj_rules));\n                } else if let Some(one_of) = val.get(\"oneOf\") {\n                    let one_of = one_of\n                        .as_array()\n                        .ok_or(anyhow!(\"`oneOf` needs to be an array\"))?;\n                    let mut rules_map: HashMap<String, Vec<SchemaValidationRule>> = HashMap::new();\n\n                    for variant in one_of {\n                        let variant_label = variant\n                            .get(\"title\")\n                            .ok_or(anyhow!(\n                                \"oneOf variant definition should have a `title` field\"\n                            ))?\n                            .as_str()\n                            .ok_or(anyhow!(\n                                \"oneOf variant definition `title` field should be a string\"\n                            ))?;\n                        if !rules_map.contains_key(variant_label) {\n                            rules_map.insert(\n                                variant_label.to_string(),\n                                SchemaValidationRule::from_value(variant)?,\n                            );\n                        } else {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L69-L105","documentation":"`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.","triggerScenarios":"A schema with `\"type\": \"object\"` and `\"oneOf\": {...}` (object/string/number instead of an array of variant schemas).","commonSituations":"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.","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."],"exampleFix":"// before\n{ \"type\": \"object\", \"oneOf\": { \"title\": \"A\" } }\n// after\n{ \"type\": \"object\", \"oneOf\": [ { \"title\": \"A\", \"type\": \"object\", \"properties\": {} } ] }","handlingStrategy":"validation","validationCode":"const s = JSON.parse(schemaRaw);\nif (\"oneOf\" in s && !Array.isArray(s.oneOf)) {\n  throw new Error(\"`oneOf` must be an array of variant schemas\");\n}","typeGuard":"function hasValidOneOf(s) {\n  return !(\"oneOf\" in s) || Array.isArray(s.oneOf);\n}","tryCatchPattern":"try {\n  await wm.deploy(script);\n} catch (e) {\n  if (String(e.message).includes(\"oneOf` needs to be an array\")) {\n    throw new Error(\"Wrap your oneOf value in an array: oneOf: [variant, ...]\");\n  } else throw e;\n}","preventionTips":["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."],"tags":["json-schema","oneof","validation","windmill"],"backgroundTag":"schema-validation-failed","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"}