{"record":{"id":"98dea70e9eacf2d2","repo":"windmill-labs/windmill","slug":"unsupported-value-for-type-field-expected-string","errorCode":null,"errorMessage":"Unsupported value for type field, expected string or string array","messagePattern":"Unsupported value for type field, expected string or string array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":181,"sourceCode":"                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                })\n                .collect::<Result<Vec<Vec<SchemaValidationRule>>, anyhow::Error>>()?;\n\n            schema_rules.push(SchemaValidationRule::IsUnionType(typ_arr));\n        } else {\n            return Err(anyhow!(\n                \"Unsupported value for type field, expected string or string array\"\n            )\n            .into());\n        }\n\n        if let Some(enum_variants) = val.get(\"enum\") {\n            let variants = enum_variants\n                .as_array()\n                .ok_or(anyhow!(\"enum variants are not in an array\"))?\n                .clone();\n            schema_rules.push(SchemaValidationRule::StrictEnum(variants));\n        }\n\n        Ok(schema_rules)\n    }\n\n    fn apply_rule(&self, key: &str, val: &Value, required: bool) -> Result<(), Error> {\n        if val.is_null() {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L163-L199","documentation":"Windmill parses JSON Schema property definitions into validation rules via SchemaValidationRule::from_value. The `type` field must be either a string (e.g. \"object\") or an array of such strings (a type union); anything else (number, object, null) is rejected. This is a schema-authoring error detected when the schema is loaded, not when data is validated.","triggerScenarios":"Calling SchemaValidationRule::from_value (indirectly through Schema::from_schema, e.g. when an app inline script's schema is reduced by reduce_app) with a property whose `type` is a non-string, non-array JSON value such as {\"type\": 1}, {\"type\": {\"a\":\"b\"}}, or {\"type\": true}.","commonSituations":"Hand-written or generated schemas where `type` was mistyped, a tool emitted `type: null` for optional fields, a schema generator produced a boolean-schema-like form, or someone confused `type` with `$ref`/`anyOf` composition.","solutions":["Set `type` to a supported string: object, array, string, number, integer, boolean, or null.","If multiple types are intended, use an array of strings, e.g. \"type\": [\"string\",\"null\"].","If the property is a union of shapes, use `anyOf` with sub-schemas instead of a complex `type`.","Remove the property or fix the generator/template that produced the malformed `type` value."],"exampleFix":"// before\n{\"myProp\": {\"type\": 1}}\n// after\n{\"myProp\": {\"type\": \"integer\"}}","handlingStrategy":"validation","validationCode":"fn validate_type_field(prop: &serde_json::Value) -> Result<(), String> {\n    let t = prop.get(\"type\").ok_or(\"missing type\")?;\n    let ok = t.as_str().is_some()\n        || t.as_array().map(|a| a.iter().all(|v| v.is_string())).unwrap_or(false);\n    if ok { Ok(()) } else { Err(\"type must be a string or array of strings\".into()) }\n}","typeGuard":"fn has_valid_type(prop: &serde_json::Value) -> bool {\n    match prop.get(\"type\") {\n        Some(v) if v.is_string() => true,\n        Some(v) if v.is_array() => v.as_array().unwrap().iter().all(|x| x.is_string()),\n        _ => false,\n    }\n}","tryCatchPattern":"match Schema::from_schema(&schema_str) {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"Unsupported value for type field\") => {\n        eprintln!(\"schema has a malformed `type` value: {e}\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Only use the seven primitive type strings: object, array, string, number, integer, boolean, null","Express nullable fields as \"type\": [\"string\",\"null\"] arrays, not null values","Use anyOf for unions of object shapes instead of exotic type values","Run the schema through a 2020-12 JSON Schema validator before deploying"],"tags":["json-schema","schema-validation","rust","windmill"],"backgroundTag":"invalid-json-schema","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"}