windmill-labs/windmill · error
Couldn't create schema validator for script requiring schema
Error message
Couldn't create schema validator for script requiring schema validation: {e} What it means
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.
Source
Thrown at backend/windmill-common/src/cache.rs:738
language: r.language,
envs: r.envs,
codebase: if let Some(use_tar) = r.use_tar {
let mut sh = hash.to_string();
if r.is_esm.unwrap_or(false) {
sh = format!("{sh}.esm");
}
if use_tar {
sh = format!("{sh}.tar");
}
Some(sh)
} else {
None
},
schema_validator: if r.schema_validation {
r.schema
.as_ref()
.map(|schema_str| {
SchemaValidator::from_schema(schema_str).map_err(|e| anyhow!("Couldn't create schema validator for script requiring schema validation: {e}"))
})
.transpose()?
} else {
None
},
schema: r.schema,
}),
})
})
}
/// Invalidate the script cache for the given `hash`.
pub fn invalidate(hash: ScriptHash) {
let _ = CACHE.remove(&hash);
}
}
pub mod app {View on GitHub (pinned to e474e8803c)
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.
Example fix
// before
"schema": "{type: object}" // not valid JSON
// after
"schema": "{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"}}}" Defensive patterns
Strategy: validation
Validate before calling
const ajv = new (require('ajv'))({ strict: true });
try { ajv.compile(JSON.parse(script.schema)); } catch (e) { throw new Error(`invalid schema on script ${script.path}: ${e.message}`); } Type guard
function isValidJsonSchema(schemaStr) { try { const s = JSON.parse(schemaStr); return typeof s === 'object' && s !== null; } catch { return false; } } Try / catch
match SchemaValidator::from_schema(schema_str) {
Ok(v) => v,
Err(e) => { /* fix the script's schema and redeploy */ return Err(...); }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Missing required arguments: ${required.join(", ")}. Use -d '
- Flow schema must be an object or null
- Field properties should be an object
- `oneOf` needs to be an array
- oneOf variant definition should have a `title` field
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/6a3b53086a059fdb.
Report an issue: GitHub.