windmill-labs/windmill · error
Problem making rule for {key}: {e}
Error message
Problem making rule for {key}: {e} What it means
When converting each entry of `properties` into validation rules via SchemaValidationRule::from_value, any per-property failure is wrapped with this message naming the property key. The underlying cause (missing `type`, unsupported type value, bad `enum`, unsupported items, etc.) is appended after the colon, so read the chained cause to find the real problem.
Source
Thrown at backend/windmill-common/src/schema.rs:549
v.as_str()
.map(|s| s.to_string())
.ok_or(anyhow!("required field key is not a string"))
})
.collect::<Result<Vec<String>, anyhow::Error>>()?;
let properties = schema
.get("properties")
.ok_or(anyhow!("Missing `properties` field on schema"))?
.as_object()
.ok_or(anyhow!("`properties` field should be an object"))?;
let mut rules = vec![];
for (key, val) in properties {
rules.push((
key.clone(),
SchemaValidationRule::from_value(val)
.map_err(|e| anyhow!("Problem making rule for {key}: {e}"))?,
));
}
Ok(Self { required, rules })
}
}
impl JsonPrimitiveType {
fn from_str(typ: &str) -> Result<Self, anyhow::Error> {
match typ {
"string" => {
return Ok(JsonPrimitiveType::String);
}
"number" => {
return Ok(JsonPrimitiveType::Number);
}
"integer" => {
return Ok(JsonPrimitiveType::Integer);View on GitHub (pinned to e474e8803c)
Solutions
- Read the error's suffix after the colon: it names the root cause and the offending property key.
- Fix that property's sub-schema (add/repair `type`, wrap `enum` in an array, add `items` for arrays, use `anyOf` for unions).
- Validate the whole schema with a standard JSON Schema 2020-12 validator before deploying to catch all offending properties at once.
- Split large schemas and test properties incrementally to isolate the failing one.
Example fix
// before
{"properties": {"count": {"typ": "integer"}}}
// after
{"properties": {"count": {"type": "integer"}}} Defensive patterns
Strategy: try-catch
Validate before calling
fn validate_all_properties(schema: &serde_json::Value) -> Result<(), String> {
let props = schema.get("properties").and_then(|p| p.as_object())
.ok_or("properties missing or not an object")?;
for (key, prop) in props {
let t = prop.get("type").ok_or_else(|| format!("{key}: missing `type`"))?;
let ok = t.is_string()
|| t.as_array().map(|a| a.iter().all(|v| v.is_string())).unwrap_or(false);
if !ok { return Err(format!("{key}: bad `type` value")); }
if let Some(e) = prop.get("enum") {
if !e.is_array() { return Err(format!("{key}: `enum` must be an array")); }
}
if t.as_str() == Some("array") && prop.get("items").is_none() {
return Err(format!("{key}: array type needs `items`"));
}
}
Ok(())
} Type guard
null
Try / catch
match Schema::from_schema(&schema_str) {
Ok(s) => s,
Err(e) => {
let msg = e.to_string();
if let Some((key, cause)) = msg.strip_prefix("Problem making rule for ")
.and_then(|rest| rest.split_once(": ")) {
eprintln!("invalid property `{key}`: {cause}");
}
return Err(e);
}
} Prevention
- Parse the "Problem making rule for <key>: <cause>" message — the suffix names the root cause
- Pre-validate each property sub-schema individually to find all failures in one pass
- Stick to the supported keyword subset: type, enum, items, anyOf, properties
- Run a standard 2020-12 validator before deploy to catch AI/template-generated schema mistakes
When it happens
Trigger: Calling Schema::from_schema where at least one property sub-schema is invalid — e.g. {"properties": {"bad": {"enum": "x"}}} yields "Problem making rule for bad: enum variants are not in an array". Reached during app reduction (reduce_app) when an inline script schema is deployed.
Common situations: One malformed property among many valid ones — typos in `type`, unsupported keywords per property (e.g. patternProperties, oneOf instead of anyOf), items missing on array types — often inside app/schemas generated by AI or templates.
Related errors
- Unsupported value for type field, expected string or string
- enum variants are not in an array
- Supplied schema draft version is unsuported
- No draft version supplied
- Missing `required` field on schema
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/db3f4caf950939ca.
Report an issue: GitHub.