windmill-labs/windmill · error

Array type should have field `items`

Error message

Array type should have field `items`

What it means

For array-typed schemas, Windmill requires an `items` schema describing the array elements, since it recursively builds validation rules from it. An array type without `items` cannot be validated and parsing fails.

Source

Thrown at backend/windmill-common/src/schema.rs:129

                    schema_rules.push(SchemaValidationRule::IsOneOf(rules_map))
                } else {
                    let is_resource = val
                        .get("format")
                        .and_then(|f| f.as_str())
                        .map(|f| f.starts_with("resource"))
                        .unwrap_or(false);
                    if !is_resource {
                        return Err(anyhow!(
                        "Object type should have a `properties` or `anyOf` field, or be a resource"
                        ));
                    }
                }
            }
            JsonPrimitiveType::Array => {
                let items = val
                    .get("items")
                    .ok_or(anyhow!("Array type should have field `items`"))?;

                let arr_rules = SchemaValidationRule::from_value(items)?;

                schema_rules.push(SchemaValidationRule::IsArray(arr_rules));
            }
            JsonPrimitiveType::Boolean => {
                schema_rules.push(SchemaValidationRule::IsBool);
            }
            JsonPrimitiveType::Null => {
                schema_rules.push(SchemaValidationRule::IsNull);
            }
        }

        Ok(schema_rules)
    }

    fn from_value(val: &Value) -> Result<Vec<Self>, Error> {
        if let Some(any_of) = val.get("anyOf").and_then(|any_of| any_of.as_array()) {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Add an `items` schema (even a permissive one such as `{}` if the parser allows it, or a concrete primitive).
  2. If elements are truly arbitrary, type the field as a JSON value/string or give `items` an object schema with `properties`.
  3. Validate the schema with a JSON Schema tool before deploying.

Example fix

// before
{ "type": "array" }
// after
{ "type": "array", "items": { "type": "string" } }
Defensive patterns

Strategy: validation

Validate before calling

const s = JSON.parse(schemaRaw);
if (s.type === "array" && !("items" in s)) {
  throw new Error("Array schema must declare `items`");
}

Type guard

function isWellFormedArraySchema(s) {
  return s?.type !== "array" || "items" in s;
}

Try / catch

try {
  await deploy(schema);
} catch (e) {
  if (String(e.message).includes("Array type should have field `items`")) {
    throw new Error("Add an items schema, e.g. items: { type: \"string\" }");
  } else throw e;
}

Prevention

When it happens

Trigger: Declaring `"type": "array"` in an input/output schema without an `items` key, e.g. `{ "type": "array" }`.

Common situations: Schemas generated by tools that omit `items` for untyped arrays; hand-written schemas; downgrading from a schema editor that strips empty `items`.

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


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/3d9effc17e089930. Report an issue: GitHub.