{"record":{"id":"db3f4caf950939ca","repo":"windmill-labs/windmill","slug":"problem-making-rule-for-key-e","errorCode":null,"errorMessage":"Problem making rule for {key}: {e}","messagePattern":"Problem making rule for (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":549,"sourceCode":"                v.as_str()\n                    .map(|s| s.to_string())\n                    .ok_or(anyhow!(\"required field key is not a string\"))\n            })\n            .collect::<Result<Vec<String>, anyhow::Error>>()?;\n\n        let properties = schema\n            .get(\"properties\")\n            .ok_or(anyhow!(\"Missing `properties` field on schema\"))?\n            .as_object()\n            .ok_or(anyhow!(\"`properties` field should be an object\"))?;\n\n        let mut rules = vec![];\n\n        for (key, val) in properties {\n            rules.push((\n                key.clone(),\n                SchemaValidationRule::from_value(val)\n                    .map_err(|e| anyhow!(\"Problem making rule for {key}: {e}\"))?,\n            ));\n        }\n\n        Ok(Self { required, rules })\n    }\n}\n\nimpl JsonPrimitiveType {\n    fn from_str(typ: &str) -> Result<Self, anyhow::Error> {\n        match typ {\n            \"string\" => {\n                return Ok(JsonPrimitiveType::String);\n            }\n            \"number\" => {\n                return Ok(JsonPrimitiveType::Number);\n            }\n            \"integer\" => {\n                return Ok(JsonPrimitiveType::Integer);","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L531-L567","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"properties\": {\"count\": {\"typ\": \"integer\"}}}\n// after\n{\"properties\": {\"count\": {\"type\": \"integer\"}}}","handlingStrategy":"try-catch","validationCode":"fn validate_all_properties(schema: &serde_json::Value) -> Result<(), String> {\n    let props = schema.get(\"properties\").and_then(|p| p.as_object())\n        .ok_or(\"properties missing or not an object\")?;\n    for (key, prop) in props {\n        let t = prop.get(\"type\").ok_or_else(|| format!(\"{key}: missing `type`\"))?;\n        let ok = t.is_string()\n            || t.as_array().map(|a| a.iter().all(|v| v.is_string())).unwrap_or(false);\n        if !ok { return Err(format!(\"{key}: bad `type` value\")); }\n        if let Some(e) = prop.get(\"enum\") {\n            if !e.is_array() { return Err(format!(\"{key}: `enum` must be an array\")); }\n        }\n        if t.as_str() == Some(\"array\") && prop.get(\"items\").is_none() {\n            return Err(format!(\"{key}: array type needs `items`\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"null","tryCatchPattern":"match Schema::from_schema(&schema_str) {\n    Ok(s) => s,\n    Err(e) => {\n        let msg = e.to_string();\n        if let Some((key, cause)) = msg.strip_prefix(\"Problem making rule for \")\n            .and_then(|rest| rest.split_once(\": \")) {\n            eprintln!(\"invalid property `{key}`: {cause}\");\n        }\n        return Err(e);\n    }\n}","preventionTips":["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"],"tags":["json-schema","schema-validation","error-wrapping","windmill"],"backgroundTag":"invalid-json-schema","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"}