{"record":{"id":"87b954720d812e19","repo":"windmill-labs/windmill","slug":"oneof-variant-definition-should-have-a-title-fie","errorCode":null,"errorMessage":"oneOf variant definition should have a `title` field","messagePattern":"oneOf variant definition should have a `title` field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":93,"sourceCode":"                    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 {\n                            return Err(anyhow!(\n                                \"oneOf definition has a duplicate variant `{variant_label}`\"\n                            ));\n                        }\n                    }\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L75-L111","documentation":"Windmill identifies each `oneOf` variant by its `title` to key validation rules and render variant selection in the UI. A variant schema in the `oneOf` array without a `title` field cannot be labeled, so `from_primitive` rejects the whole schema.","triggerScenarios":"A `oneOf` array whose element schema lacks a top-level `\"title\"` string, e.g. `\"oneOf\": [{ \"type\": \"object\", \"properties\": {} }]` with no `title`.","commonSituations":"Schemas generated by external tools (OpenAPI generators, editors) that omit `title` on variants; stripping titles when copying schemas; minimal hand-written variants.","solutions":["Add a unique string `title` to every schema in the `oneOf` array.","If the variant comes from a generator, configure it to emit titles or add them post-generation.","Replace `oneOf` with `anyOf`/`properties` if variant labels are not needed."],"exampleFix":"// before\n{ \"oneOf\": [ { \"type\": \"object\" } ] }\n// after\n{ \"oneOf\": [ { \"title\": \"Option A\", \"type\": \"object\" } ] }","handlingStrategy":"validation","validationCode":"const s = JSON.parse(schemaRaw);\nif (Array.isArray(s.oneOf)) {\n  const missing = s.oneOf.filter(v => typeof v?.title !== \"string\");\n  if (missing.length) throw new Error(\"Every oneOf variant needs a string `title`\");\n}","typeGuard":"function hasTitledVariants(s) {\n  return !Array.isArray(s.oneOf) || s.oneOf.every(v => typeof v?.title === \"string\");\n}","tryCatchPattern":"try {\n  await deploy(schema);\n} catch (e) {\n  if (String(e.message).includes(\"should have a `title` field\")) {\n    throw new Error(\"Add a unique string title to each oneOf variant\");\n  } else throw e;\n}","preventionTips":["Always add a title to every oneOf variant — Windmill uses it as the variant key and UI label.","When importing schemas from generators, post-process to inject titles.","Lint schemas in CI for required titles on oneOf members."],"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"}