{"record":{"id":"f187cc18a2a7ecd1","repo":"windmill-labs/windmill","slug":"required-field-key-is-not-a-string","errorCode":null,"errorMessage":"required field key is not a string","messagePattern":"required field key is not a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/schema.rs","lineNumber":533,"sourceCode":"        if let Some(draft_version) = schema.get(\"$schema\") {\n            match draft_version.as_str() {\n                Some(\"https://json-schema.org/draft/2020-12/schema\") => (),\n                _ => return Err(anyhow!(\"Supplied schema draft version is unsuported\").into()),\n            }\n        } else {\n            return Err(anyhow!(\"No draft version supplied\").into());\n        }\n\n        let required: Vec<String> = schema\n            .get(\"required\")\n            .ok_or(anyhow!(\"Missing `required` field on schema\"))?\n            .as_array()\n            .ok_or(anyhow!(\"`required` field should be an array of strings\"))?\n            .into_iter()\n            .map(|v| {\n                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        }","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/schema.rs#L515-L551","documentation":"Raised by from_schema when an entry inside the schema's `required` array is not a string. Each entry must name a property; non-string entries would compile into unusable validation rules, so the schema is rejected during parsing.","triggerScenarios":"Calling Schema::from_schema with \"required\": [1, \"a\"], \"required\": [null], or \"required\": [{\"name\":\"a\"}] — at least one element is not a JSON string.","commonSituations":"Programmatic schema construction where numbers/objects were pushed into the required list, JSON5/JS arrays with mixed types, and schemas copied from formats where required entries carry extra structure.","solutions":["Make every entry of `required` a plain string naming a property, e.g. \"required\": [\"a\",\"b\"].","Fix the generating code to serialize property names (to_string/name) instead of raw objects or numbers."],"exampleFix":"// before\n\"required\": [{\"name\": \"a\"}, 2]\n// after\n\"required\": [\"a\"]","handlingStrategy":"type-guard","validationCode":"fn validate_required_elements(schema: &serde_json::Value) -> Result<(), String> {\n    let arr = schema.get(\"required\").and_then(|r| r.as_array())\n        .ok_or(\"required missing or not an array\")?;\n    for (i, v) in arr.iter().enumerate() {\n        if !v.is_string() {\n            return Err(format!(\"required[{i}] must be a string, got {v}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn all_required_strings(schema: &serde_json::Value) -> bool {\n    schema.get(\"required\").and_then(|r| r.as_array())\n        .map(|a| a.iter().all(|v| v.is_string()))\n        .unwrap_or(false)\n}","tryCatchPattern":"match Schema::from_schema(&schema_str) {\n    Ok(s) => s,\n    Err(e) if e.to_string().contains(\"required field key is not a string\") => {\n        eprintln!(\"every `required` entry must be a plain property-name string\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Build required arrays with map(name) in generators so entries are always strings","Validate array homogeneity before passing the schema"],"tags":["json-schema","schema-validation","type-mismatch","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"}