{"record":{"id":"0ba9ffdbd6965f77","repo":"windmill-labs/windmill","slug":"missing-type-field","errorCode":null,"errorMessage":"Missing `type` field","messagePattern":"Missing `type` field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":158,"sourceCode":"            }\n        }\n\n        Ok(schema_rules)\n    }\n\n    fn from_value(val: &Value) -> Result<Vec<Self>, Error> {\n        if let Some(any_of) = val.get(\"anyOf\").and_then(|any_of| any_of.as_array()) {\n            let mut r = vec![];\n\n            for variant in any_of {\n                r.push(SchemaValidationRule::from_value(variant)?);\n            }\n            return Ok(vec![SchemaValidationRule::IsUnionType(r)]);\n        }\n\n        let mut schema_rules = vec![];\n\n        let typ = val.get(\"type\").ok_or(anyhow!(\"Missing `type` field\"))?;\n\n        if let Some(typ) = typ.as_str() {\n            schema_rules.append(&mut SchemaValidationRule::from_primitive(\n                &JsonPrimitiveType::from_str(typ)?,\n                val,\n            )?);\n        } else if let Some(typ_arr) = typ.as_array() {\n            let typ_arr = typ_arr\n                .into_iter()\n                .map(|v| {\n                    SchemaValidationRule::from_primitive(\n                        &JsonPrimitiveType::from_str(\n                            v.as_str()\n                                .ok_or(anyhow!(\"Expected array of strings for `type` field\"))?,\n                        )?,\n                        v,\n                    )\n                })","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L140-L176","documentation":"`SchemaValidationRule::from_value` first checks for a single string `type`. When absent (and the value is not a union handled earlier), it errors because Windmill cannot build validation rules for a schema with no declared type. This runs when apps/flows parse embedded JSON schemas (e.g. via reduce_app).","triggerScenarios":"A schema node without a `type` field (and without the union/oneOf shapes handled before this branch), e.g. `{ \"properties\": {...} }` alone, parsed during app reduction or deployment.","commonSituations":"Schemas relying on implicit typing that Windmill does not support; partial schema fragments copied into Windmill; generator output omitting `type` when it can be inferred.","solutions":["Add an explicit `\"type\": \"string|number|integer|boolean|object|array\"` to the schema node.","If the value can be multiple types, supply `\"type\": [...]` array form (see error 939).","If using object variants, wrap them in `oneOf` with titles so the union branch is taken."],"exampleFix":"// before\n{ \"properties\": { \"a\": { \"type\": \"string\" } } }\n// after\n{ \"type\": \"object\", \"properties\": { \"a\": { \"type\": \"string\" } } }","handlingStrategy":"validation","validationCode":"const s = JSON.parse(schemaRaw);\nconst PRIMITIVES = [\"string\", \"number\", \"integer\", \"boolean\", \"object\", \"array\"];\nif (!Array.isArray(s.type) && typeof s.type !== \"string\") {\n  throw new Error(\"Schema node needs a string `type` (or a type array)\");\n}","typeGuard":"function hasDeclaredType(s) {\n  return typeof s?.type === \"string\" || Array.isArray(s?.type);\n}","tryCatchPattern":"try {\n  await deployApp(app);\n} catch (e) {\n  if (String(e.message).includes(\"Missing `type` field\")) {\n    throw new Error(\"Add an explicit `type` to the offending schema node (Windmill does not infer types)\");\n  } else throw e;\n}","preventionTips":["Windmill requires explicit types — never rely on JSON Schema inference.","When copying schema fragments, keep their `type` fields.","Walk the whole schema tree in a pre-deploy check to ensure every node has `type` or `oneOf`."],"tags":["json-schema","missing-field","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"}