windmill-labs/windmill · error
enum variants are not in an array
Error message
enum variants are not in an array
What it means
When a property schema includes an `enum` keyword, Windmill requires its value to be a JSON array of allowed variants (converted to a StrictEnum validation rule). If `enum` is present but not an array, from_value rejects the schema. The check only fires when `enum` exists, so omitting it entirely is fine.
Source
Thrown at backend/windmill-common/src/schema.rs:190
.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"))?
.clone();
schema_rules.push(SchemaValidationRule::StrictEnum(variants));
}
Ok(schema_rules)
}
fn apply_rule(&self, key: &str, val: &Value, required: bool) -> Result<(), Error> {
if val.is_null() {
if !required {
return Ok(());
}
return Err(Error::ArgumentErr(format!("Argument {key} cannot be null")));
}
match self {
SchemaValidationRule::IsNull => {
if !val.is_null() {
return Err(Error::ArgumentErr(format!(View on GitHub (pinned to e474e8803c)
Solutions
- Wrap the variants in a JSON array: "enum": ["red","green","blue"].
- If you did not intend an enumeration, remove the `enum` key entirely.
- Check the schema-generating code for a missing collect/wrap step around the variant list.
Example fix
// before
{"status": {"type": "string", "enum": "active"}}
// after
{"status": {"type": "string", "enum": ["active", "inactive"]}} Defensive patterns
Strategy: validation
Validate before calling
fn validate_enum_field(prop: &serde_json::Value) -> Result<(), String> {
if let Some(e) = prop.get("enum") {
if !e.is_array() {
return Err("`enum` must be a JSON array of allowed values".into());
}
}
Ok(())
} Type guard
fn has_valid_enum(prop: &serde_json::Value) -> bool {
prop.get("enum").map(|e| e.is_array()).unwrap_or(true)
} Try / catch
match Schema::from_schema(&schema_str) {
Ok(s) => s,
Err(e) if e.to_string().contains("enum variants are not in an array") => {
eprintln!("fix the `enum` key: it must be an array: {e}");
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Always write enum as an array, even for a single allowed value
- Never paste language-level enums as scalars — serialize their variant list
- Lint schemas so any `enum` key is checked with Array.isArray / Value::is_array
When it happens
Trigger: from_value (via Schema::from_schema during app reduction) sees a property like {"type":"string","enum":"red"} or {"enum": {"a":1}} — `enum` is any non-array JSON value.
Common situations: Copy-pasting an enum from a programming-language definition into the schema as a scalar, a generator emitting `enum` as a comma-separated string, or accidental JSON editing that dropped the brackets.
Related errors
- Unsupported value for type field, expected string or string
- Supplied schema draft version is unsuported
- No draft version supplied
- Missing `required` field on schema
- `required` field should be an array of strings
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/fafea02e04e555fa.
Report an issue: GitHub.