windmill-labs/windmill · error
Expected array of strings for `type` field
Error message
Expected array of strings for `type` field
What it means
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.
Source
Thrown at backend/windmill-common/src/schema.rs:172
}
let mut schema_rules = vec![];
let typ = val.get("type").ok_or(anyhow!("Missing `type` field"))?;
if let Some(typ) = typ.as_str() {
schema_rules.append(&mut SchemaValidationRule::from_primitive(
&JsonPrimitiveType::from_str(typ)?,
val,
)?);
} else if let Some(typ_arr) = typ.as_array() {
let typ_arr = typ_arr
.into_iter()
.map(|v| {
SchemaValidationRule::from_primitive(
&JsonPrimitiveType::from_str(
v.as_str()
.ok_or(anyhow!("Expected array of strings for `type` field"))?,
)?,
v,
)
})
.collect::<Result<Vec<Vec<SchemaValidationRule>>, anyhow::Error>>()?;
schema_rules.push(SchemaValidationRule::IsUnionType(typ_arr));
} else {
return Err(anyhow!(
"Unsupported value for type field, expected string or string array"
)
.into());
}
if let Some(enum_variants) = val.get("enum") {
let variants = enum_variants
.as_array()
.ok_or(anyhow!("enum variants are not in an array"))?View on GitHub (pinned to e474e8803c)
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.
Example fix
// before
{ "type": ["string", "null"] }
// after
{ "anyOf": [ { "title": "Value", "type": "string" }, { "title": "Empty", "type": "object", "properties": {} } ] } Defensive patterns
Strategy: validation
Validate before calling
const s = JSON.parse(schemaRaw);
if (Array.isArray(s.type)) {
const bad = s.type.filter(t => typeof t !== "string");
if (bad.length) throw new Error("Every entry in the `type` array must be a primitive string");
} Type guard
function hasStringTypeUnion(s) {
return !Array.isArray(s?.type) || s.type.every(t => typeof t === "string");
} Try / catch
try {
await deploy(schema);
} catch (e) {
if (String(e.message).includes("Expected array of strings for `type` field")) {
throw new Error("Use only primitive strings in the type array; avoid null entries");
} else throw e;
} Prevention
- 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.
When it happens
Trigger: A schema like `"type": ["string", 1]` or `"type": ["string", null]` parsed by `from_value` during app/flow schema ingestion.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Field properties should be an object
- `oneOf` needs to be an array
- oneOf variant definition should have a `title` field
- oneOf variant definition `title` field should be a string
- Object type should have a `properties` or `anyOf` field, or
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/2532fb6816129e15.
Report an issue: GitHub.