{"record":{"id":"2532fb6816129e15","repo":"windmill-labs/windmill","slug":"expected-array-of-strings-for-type-field","errorCode":null,"errorMessage":"Expected array of strings for `type` field","messagePattern":"Expected array of strings for `type` field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":172,"sourceCode":"        }\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                })\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\"))?","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L154-L190","documentation":"When `type` is given as an array (union type), `from_value` maps each element through `JsonPrimitiveType::from_str`, which requires a string. Any non-string element in the `type` array (or a null entry) fails with this error.","triggerScenarios":"A schema like `\"type\": [\"string\", 1]` or `\"type\": [\"string\", null]` parsed by `from_value` during app/flow schema ingestion.","commonSituations":"Programmatic schema generation inserting non-string type ids; YAML unquoted types coercing to numbers/booleans; JSON Schema draft features (e.g. `\"type\": [\"string\", \"null\"]`) where the null member is not a Windmill primitive.","solutions":["Ensure every entry in the `type` array is a valid primitive string (string, number, integer, boolean, object, array).","Remove `null` entries; express nullability the way Windmill supports (e.g. anyOf with an empty variant) instead of \"null\".","Quote values in YAML so they stay strings."],"exampleFix":"// before\n{ \"type\": [\"string\", \"null\"] }\n// after\n{ \"anyOf\": [ { \"title\": \"Value\", \"type\": \"string\" }, { \"title\": \"Empty\", \"type\": \"object\", \"properties\": {} } ] }","handlingStrategy":"validation","validationCode":"const s = JSON.parse(schemaRaw);\nif (Array.isArray(s.type)) {\n  const bad = s.type.filter(t => typeof t !== \"string\");\n  if (bad.length) throw new Error(\"Every entry in the `type` array must be a primitive string\");\n}","typeGuard":"function hasStringTypeUnion(s) {\n  return !Array.isArray(s?.type) || s.type.every(t => typeof t === \"string\");\n}","tryCatchPattern":"try {\n  await deploy(schema);\n} catch (e) {\n  if (String(e.message).includes(\"Expected array of strings for `type` field\")) {\n    throw new Error(\"Use only primitive strings in the type array; avoid null entries\");\n  } else throw e;\n}","preventionTips":["Avoid `null` in type unions — Windmill primitives do not include \"null\".","Quote YAML type values so they do not coerce to non-strings.","Generate unions from a fixed list of allowed primitive names."],"tags":["json-schema","union-type","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"}