{"record":{"id":"6a3b53086a059fdb","repo":"windmill-labs/windmill","slug":"couldn-t-create-schema-validator-for-script-requir","errorCode":null,"errorMessage":"Couldn't create schema validator for script requiring schema validation: {e}","messagePattern":"Couldn't create schema validator for script requiring schema validation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-common/src/cache.rs","lineNumber":738,"sourceCode":"                    language: r.language,\n                    envs: r.envs,\n                    codebase: if let Some(use_tar) = r.use_tar {\n                        let mut sh = hash.to_string();\n                        if r.is_esm.unwrap_or(false) {\n                            sh = format!(\"{sh}.esm\");\n                        }\n                        if use_tar {\n                            sh = format!(\"{sh}.tar\");\n                        }\n                        Some(sh)\n                    } else {\n                        None\n                    },\n                    schema_validator: if r.schema_validation {\n                        r.schema\n                            .as_ref()\n                            .map(|schema_str| {\n                                SchemaValidator::from_schema(schema_str).map_err(|e| anyhow!(\"Couldn't create schema validator for script requiring schema validation: {e}\"))\n                            })\n                            .transpose()?\n                    } else {\n                        None\n                    },\n                    schema: r.schema,\n                }),\n            })\n        })\n    }\n\n    /// Invalidate the script cache for the given `hash`.\n    pub fn invalidate(hash: ScriptHash) {\n        let _ = CACHE.remove(&hash);\n    }\n}\n\npub mod app {","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-common/src/cache.rs#L720-L756","documentation":"When caching a script, if the script has `schema_validation` enabled, the stored JSON schema is compiled into a SchemaValidator at cache time. If the schema string is malformed (not valid JSON Schema) compilation fails and this error wraps the underlying cause. The script cannot be cached/executed until its schema is fixed.","triggerScenarios":"Loading a script into the script cache (backend/windmill-common/src/cache.rs:738) where r.schema_validation is true and SchemaValidator::from_schema rejects the schema string — invalid JSON, unsupported schema keywords/dialect, or empty/corrupted schema.","commonSituations":"Hand-edited schemas with JSON syntax errors; schemas written for a different validator dialect; payloads pasted from other tools with $ref to external documents; migration leaving a legacy schema string the current validator can't parse.","solutions":["Validate the script's `schema` field with a JSON Schema validator (e.g. ajv in strict mode) and fix syntax/dialect errors.","Ensure the schema is a complete JSON Schema object (type/properties at root), not a fragment or quoted string of JSON.","Disable schema_validation on the script if validation is not actually needed.","Re-deploy the script after fixing so the cache rebuilds with a valid validator."],"exampleFix":"// before\n\"schema\": \"{type: object}\"            // not valid JSON\n// after\n\"schema\": \"{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"name\\\":{\\\"type\\\":\\\"string\\\"}}}\"","handlingStrategy":"validation","validationCode":"const ajv = new (require('ajv'))({ strict: true });\ntry { ajv.compile(JSON.parse(script.schema)); } catch (e) { throw new Error(`invalid schema on script ${script.path}: ${e.message}`); }","typeGuard":"function isValidJsonSchema(schemaStr) { try { const s = JSON.parse(schemaStr); return typeof s === 'object' && s !== null; } catch { return false; } }","tryCatchPattern":"match SchemaValidator::from_schema(schema_str) {\n    Ok(v) => v,\n    Err(e) => { /* fix the script's schema and redeploy */ return Err(...); }\n}","preventionTips":["Validate schemas with a strict JSON Schema tool before deploying scripts","Keep schemas self-contained (no external $ref)","Store schema as a JSON object, not a fragment","Re-deploy after schema edits so the cache rebuilds"],"tags":["json-schema","validation","cache","script"],"backgroundTag":"schema-validation-failed","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"}